window.dataLayer = window.dataLayer || [];
- Job
- Creates the array if it does not exist. Place it near the top of the page, before the container snippet
The data layer is a JavaScript array that passes page information to Google Tag Manager. How push works, the event key, common mistakes and a console check.
The data layer is a JavaScript array, window.dataLayer, that holds information passed from your site to Google Tag Manager or gtag.js. Tags can fire on events you push or on variable values you set, so the page and the tags stay decoupled.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
window.dataLayer = window.dataLayer || [];'event': 'sign_up_click''plan_name': 'starter'pushwindow.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'sign_up_click',
'plan_name': 'starter'
});Names here are examples. Use one variable name for one concept on every page, as Google advises.
window.dataLayerdataLayer is case-sensitivedatalayer.push failsIf window.dataLayer is undefined, the array was never declared or the container is not on that page.
window.dataLayer
// then push a test event and watch it in GTM Preview:
window.dataLayer.push({ event: 'console_test' });2 questions people ask next, answered from the sources on this page.
The data layer is the array that holds your data. Tag Manager is the container that reads it and fires tags.
Yes. Google says you can rename it by changing the snippet parameter, and for gtag.js by adding the l query parameter.
The free audit reads robots.txt, sitemaps, status codes, canonicals, redirects and structured data.