Google gtag Issue

Avatar

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

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

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
scottt6073095
Level 4

14-11-2018

anyone successfully implement and use the new Google gtag code in Adobe Launch. we keep getting errors as a result of there code when we test in dev. I thought I would ask here before contacting Google directly to see if there was a remedy.

Errors:

  • Uncaught TypeError: dataLayer.push is not a function
  • [Core] Script error. - : 0
  • Uncaught TypeError: a.slice is not a function

We also tried using the new gtag extension someone built but get the same errors. One of the issues is probably because we have an object called "dataLayer" that loads all our pageload data as well. The slice error is coming from the first script tag that references GTM source: src="https://www.googletagmanager.com/gtag/js?id=AW-someaccountcode".

1621921_pastedImage_0.png

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Seeker
Employee
brandon_pack
Employee

Likes

30 likes

Total Posts

40 posts

Correct reply

10 solutions
Top badges earned
Seeker
Unlock
Publish 1
Ignite 1
Give Back 3
View profile

Avatar
Seeker
Employee
brandon_pack
Employee

Likes

30 likes

Total Posts

40 posts

Correct reply

10 solutions
Top badges earned
Seeker
Unlock
Publish 1
Ignite 1
Give Back 3
View profile
brandon_pack
Employee

02-01-2019

This change has been pushed to production.  In the configuration view you can customize the DataLayer name:

gtag.png

Answers (11)

Answers (11)

Avatar

Avatar
Seeker
Employee
brandon_pack
Employee

Likes

30 likes

Total Posts

40 posts

Correct reply

10 solutions
Top badges earned
Seeker
Unlock
Publish 1
Ignite 1
Give Back 3
View profile

Avatar
Seeker
Employee
brandon_pack
Employee

Likes

30 likes

Total Posts

40 posts

Correct reply

10 solutions
Top badges earned
Seeker
Unlock
Publish 1
Ignite 1
Give Back 3
View profile
brandon_pack
Employee

15-11-2018

We are working on adding a new parameter to the gtag extension configuration view that would allow you to rename Google's dataLayer to something else so that it would not conflict.  Hope to be able to get it released before too long but not exact date commitments at this point.

Avatar

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

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

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
scottt6073095
Level 4

15-01-2019

awesome!! thank you for adding the custom datalayer name. Everything works great now

Avatar

Avatar
Seeker
Employee
brandon_pack
Employee

Likes

30 likes

Total Posts

40 posts

Correct reply

10 solutions
Top badges earned
Seeker
Unlock
Publish 1
Ignite 1
Give Back 3
View profile

Avatar
Seeker
Employee
brandon_pack
Employee

Likes

30 likes

Total Posts

40 posts

Correct reply

10 solutions
Top badges earned
Seeker
Unlock
Publish 1
Ignite 1
Give Back 3
View profile
brandon_pack
Employee

03-12-2018

Yeah this is code-complete and being tested but Adobe has a polciy to not release or change production code during the holiday when it's a very sensative time and there is less appetite for risk.  So this is likely to be released the first week of January.   If you are willing to test it before then, we can upload it to your org as a Private Extension and you could use it sooner.  It would however mean re-creating your rules if you wanted toswitch to the public one in January and take advatange of future updates.  But let us know.

Avatar

Avatar
Validate 1
Level 8
thomas_amsler
Level 8

Likes

244 likes

Total Posts

159 posts

Correct reply

26 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 8
thomas_amsler
Level 8

Likes

244 likes

Total Posts

159 posts

Correct reply

26 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
thomas_amsler
Level 8

15-11-2018

push and splice are methods of the JavaScript Array object​. So if you have an object called dataLayer and the gtag expects the dataLayer to be an array, this error makes sense. a probably is just a reference to the same dataLayer object within a function. You probably have to rename your custom dataLayer object so it doesn't interfere with what gtag expects.

Avatar

Avatar
Boost 5
Employee
garretth7904271
Employee

Likes

6 likes

Total Posts

11 posts

Correct reply

5 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile

Avatar
Boost 5
Employee
garretth7904271
Employee

Likes

6 likes

Total Posts

11 posts

Correct reply

5 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Applaud 5
Affirm 5
View profile
garretth7904271
Employee

22-01-2019

Hi Brandon,

Is there a way to address this same issue within DTM? Any help on why this error occurs would be helpful.

Is the issue due to google expecting the data layer to be an object rather than an array? That's what is suggested here Google Tag Manager error: Uncaught TypeError: w[l].push is not a function - Stack Overflow Could the issue be addressed within dtm by placing the data layer in an array?

Avatar

Avatar
Coach
Employee
Gigazelle
Employee

Likes

473 likes

Total Posts

1,947 posts

Correct reply

740 solutions
Top badges earned
Coach
Contributor 2
Validate 1
Ignite 80
Ignite 70
View profile

Avatar
Coach
Employee
Gigazelle
Employee

Likes

473 likes

Total Posts

1,947 posts

Correct reply

740 solutions
Top badges earned
Coach
Contributor 2
Validate 1
Ignite 80
Ignite 70
View profile
Gigazelle
Employee

17-12-2018

It will just be for Launch. You will want to use custom code if you intend to do it for DTM.

Avatar

Avatar
Boost 1
Level 1
leos66376844
Level 1

Like

1 like

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
leos66376844
Level 1

Like

1 like

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
leos66376844
Level 1

03-12-2018

Thank you for following up. Is there something similar for DTM?

Avatar

Avatar
Boost 1
Level 1
leos66376844
Level 1

Like

1 like

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
leos66376844
Level 1

Like

1 like

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
leos66376844
Level 1

29-11-2018

Has there been an update on this?

Avatar

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

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

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
scottt6073095
Level 4

19-11-2018

that would be great, can't wait.

thanks for the feedback

Avatar

Avatar
Validate 1
Level 8
thomas_amsler
Level 8

Likes

244 likes

Total Posts

159 posts

Correct reply

26 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 8
thomas_amsler
Level 8

Likes

244 likes

Total Posts

159 posts

Correct reply

26 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
thomas_amsler
Level 8

15-11-2018

I don't know gtag, so I can't help there, but maybe you can configure gtag so the object it relies on is called differently.

One other, more complex solution would be to "mask" it by implementing all the array methods in your object and use them to operate on an internal array:

dataLayer._gtagDataLayer = [];

dataLayer.push = function(obj) {

    this._gtagDataLayer.push(obj);

};

dataLayer.pop = function() {

    return this._gtagDataLayer.pop();

};

//etc.

But again, maybe the dataLayer object from gtag has other functionality as you can do crazy stuff with javascript, so probably also ask in their forums how to proceed.

Avatar

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

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

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
scottt6073095
Level 4

15-11-2018

unfortunately we cannot change the name of our main object as this is used globally for data collection.

thanks