Google gtag Issue | Community
Skip to main content
Level 4
November 15, 2018
Solved

Google gtag Issue

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".

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
brandon_pack
brandon_packAccepted solution
Employee
January 2, 2019

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

12 replies

Level 4
November 15, 2018

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

thanks

Translate
Level 6
November 15, 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.

Translate