Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Google gtag in DTM

Avatar

Avatar
Validate 1
Level 2
vipinvijayan10
Level 2

Likes

8 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile

Avatar
Validate 1
Level 2
vipinvijayan10
Level 2

Likes

8 likes

Total Posts

7 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
View profile
vipinvijayan10
Level 2

20-12-2018

Hello Everyone!

Just wanted to know how do you guys deploy the Google gtag via DTM to collect the audiences for remarketing lists in DV360 or Google Ads?

As instructed by stewarts16448458​ on this thread, I deployed the gtag as a page top rule (Sequential HTML), however the Remarketing lists within the Google Ads  UI weren't populating. When I checked with the Google Ads Support team, they got back to me saying that the setup isn't right as they want the gtag to be injected directly on the page (i.e. not in an iframe and not run server-side).

So I tried converting the gtag to JS as shown below and it looks it is working. However I'd love to know if you know of any easier and efficient way of doing this.

var dcJS = document.createElement("SCRIPT");

var done = false;

dcJS.setAttribute("src", "//www.googletagmanager.com/gtag/js?id=AW-XXXXXXXX");

dcJS.setAttribute("type", "text/javascript");

document.body.appendChild(dcJS);

dcJS.onload = dcJS.onreadystatechange = function() {

  if (

    !done &&

    (!this.readyState ||

      this.readyState === "loaded" ||

      this.readyState === "complete")

  ) {

    done = true;

    callback();

    // Handle memory leak in IE

    dcJS.onload = dcJS.onreadystatechange = null;

    document.body.removeChild(dcJS);

  }

};

function callback() {

  if (done) {

    /* <![CDATA[ */

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

    function gtag() {

      dataLayer.push(arguments);

    }

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

    gtag("config", "AW-XXXXXXXXX");

  }

  //]]>

}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
StewSchilling
MVP

Likes

342 likes

Total Posts

278 posts

Correct Reply

85 solutions
Top badges earned
Coach
Give Back 25
Springboard
Bedrock
Validate 1
View profile

Avatar
Coach
MVP
StewSchilling
MVP

Likes

342 likes

Total Posts

278 posts

Correct Reply

85 solutions
Top badges earned
Coach
Give Back 25
Springboard
Bedrock
Validate 1
View profile
StewSchilling
MVP

20-12-2018

Are you absolutely sure that you deployed it as Sequential HTML?

What you describe (loading in an iframe) would indicate that it had been deployed as Non-Sequential HTML. 

Answers (1)

Answers (1)

Avatar

Avatar
Coach
MVP
StewSchilling
MVP

Likes

342 likes

Total Posts

278 posts

Correct Reply

85 solutions
Top badges earned
Coach
Give Back 25
Springboard
Bedrock
Validate 1
View profile

Avatar
Coach
MVP
StewSchilling
MVP

Likes

342 likes

Total Posts

278 posts

Correct Reply

85 solutions
Top badges earned
Coach
Give Back 25
Springboard
Bedrock
Validate 1
View profile
StewSchilling
MVP

04-01-2019

Have you had a chance to check on this?  If my suggested solution did not work, I really would like to understand what went wrong.

-Stew