gtag.js Implementation - Global & Event | Community
Skip to main content
August 27, 2018
Solved

gtag.js Implementation - Global & Event

  • August 27, 2018
  • 1 reply
  • 3073 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by LeoS_Taco

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?

1 reply

LeoS_Taco
LeoS_TacoAccepted solution
Level 2
September 28, 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?