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 Conversion Tracking Tag

Avatar

Avatar
Validate 10
Level 2
vitalin58577727
Level 2

Likes

15 likes

Total Posts

69 posts

Correct Reply

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

Avatar
Validate 10
Level 2
vitalin58577727
Level 2

Likes

15 likes

Total Posts

69 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 5
Boost 3
Boost 10
View profile
vitalin58577727
Level 2

19-03-2019

Hello, everyone,

I want to implement the new Google Conversion Tracking tag in Adobe Tag Manager.

Can anyone help me?

<!-- Global site tag (gtag.js) - Google Ads: 123456789 -->

<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>

<script>

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

  function gtag(){dataLayer.push(arguments);}

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

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

</script>

<!-- Event snippet for Example conversion page -->

<script>

  gtag('event', 'conversion', {'send_to': 'AW-123456789/AbC-D_efG-h12_34-567',

    'value': 1.0,

    'currency': 'USD'

  });

</script>

From this I would like to make the following:

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

1 var done = false;

2  

3 dcJS.setAttribute('src', 'https://www.googletagmanager.com/gtag/js?id=' + document.__dtm_googleConversionIDGST[0] + ';');

4 dcJS.setAttribute('type','text/javascript');

5  

6 document.body.appendChild(dcJS);

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

8    if(!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) {

9    done = true;

10    callback();

11  

12    // Handle memory leak in IE

13    dcJS.onload = dcJS.onreadystatechange = null;

14    document.body.removeChild(dcJS);

15    }

16 };

17 function callback(){

18    if(done){ 

19    /* <![CDATA[ */

20    window.google_trackConversion({

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

22    function gtag(){dataLayer.push(arguments);}

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

24    gtag('config', '" + document.__dtm_googleConversionIDGST[0] + "');

25    });

26    //]]>

27    }

28 }

But you can't.

I get error messages.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Applaud 500
MVP
Asheesh_P
MVP

Likes

129 likes

Total Posts

334 posts

Correct Reply

144 solutions
Top badges earned
Applaud 500
Affirm 100
Contributor
Boost 100
Give Back 10
View profile

Avatar
Applaud 500
MVP
Asheesh_P
MVP

Likes

129 likes

Total Posts

334 posts

Correct Reply

144 solutions
Top badges earned
Applaud 500
Affirm 100
Contributor
Boost 100
Give Back 10
View profile
Asheesh_P
MVP

24-03-2019

I would do the following.

Go to the third-party section of the rule select async javascript option in DTM.  (set conversion tag fire condition in the rule itself)

1. Add the following code to set gtag.js

     Note: //Replace "AW-123456789" with your AdWords account id.

_satellite.loadScript("https://www.googletagmanager.com/gtag/js?id=AW-123456789"); //Replace "AW-123456789" with your adword account id.

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

                    function gtag() {

                        dataLayer.push(arguments)

                    };

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

                    gtag('config', 'AW-123456789');  //Replace "AW-123456789" with your adword account id.

                };

2. Now set following conversion code.

gtag('event', 'conversion', {'send_to': 'AW-123456789/AbC-D_efG-h12_34-567', //Replace "AW-123456789" with your adword account id/value.

    'value': 1.0,

    'currency': 'USD'

  });

Note:

//Replace "AW-123456789" with your AdWords account id and "AbC-D_efG-h12_34-567" with conversion value id.

//Replace event "conversion" with custom conversion event eg. "view_item" etc.

Not sure what "document.__dtm_googleConversionIDGST[0]"  does in your code, but in case you want to pass additional data on the conversion, use conversion code section instead. Remove comments in code anything after // ... before publishing in DTM.

Good Luck!

Asheesh

Answers (0)