gtag.js Implementation - Global & Event

chrisc97334336

27-08-2018

Hello Adobe DTM Community,

Reaching out to see if anyone can provide some guidance on the implementation of the gtag.js global (base) and event tag. As the event tag pulls in page data layer values these tags have been implemented as non-sequential JS tags. As the global tag needs to fire first, a page rule has been set up to fire the global tag at the bottom of the page, and a separate page rule set up to fire the event tag on page load. With this configuration I am running into the issue where "gtag" is undefined when the event tag fires. Any assistance regarding this implementation will be very appreciated. 

Global:

DTM.loadScriptCallback("https://www.googletagmanager.com/gtag/js?id=AW-12345678", function() {

    window.dataLayer = window.dataLayer || [];

    function gtag() {

        dataLayer.push(arguments);

    }

    gtag('js', new Date());

    gtag('config', 'AW-12345678');

    gtag('config', 'DC-87654321');

});

Event:

var productID = DTM.getVariable("product")[0].productInfo.productID;

    gtag('event', 'page_view', {

        'send_to': 'AW-12345678',

        'ecomm_prodid': productID

    });

Thank you.

Accepted Solutions (1)

Accepted Solutions (1)

LeoS_Taco

28-09-2018

I believe you would place the first tag in a page load rule's JavaScript/Third Party Tags section. And then you place the Event rule in the any particular event Javascript/Third Party Tags section. Does that make sense?

Answers (0)