내 커뮤니티 업적 표시줄을 확대합니다.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Google gtag in DTM

Avatar

Level 2

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");

  }

  //]]>

}

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

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. 

원본 게시물의 솔루션 보기

2 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

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. 

Avatar

Community Advisor

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