Subscribe to our monthly newsletter to get the latest updates in your inbox
We are pleased to launch the latest version of the Data Layer Inspector+. In addition to the new branding, we've added features and functions that can make an analyst’s life easier.
What is the Inspector+?
The Data Layer Inspector+ is a Chrome extension that provides real-time, information-rich viewing of dataLayer activity and Google Analytics hits as they happen in the Developer Tools console. In addition, it has other features that support development and web analytics debugging.
Feature Summary
The UI has been updated to pack all the features into a compact, easy-to-use set of options.
Added Functionality
Provides additional abilities, beyond the basic features including:
- Push events to the dataLayer
- Insert a GTM container
- Add code to the page
- Block and swap network requests
Control Output
Enhance or hide outputs, including:
- Timing,
- postMessages
- DOM mutations
- Console highlights
- Call stack
- Internal redirects (302s)
- Specific events
- Specific properties
- CD names.
Other Analytics
Observe code and network activity for other analytics implementations; Adobe DTM, Adobe Analytics, Tealium, Facebook, DoubleClick and Custom.
Handy Links
Get links to relevant documentation and resources.Basic use
Badge
The badge will indicate current settings with color and short text. – On
– Off
– Classic Mode
– dataLayer.push
– GTM Inserted
– Multiple Added Functions
– Code inserted or Block and Swap on
Console Output
Banner
HRef
Href is document.location.href at the time the Inspector loads on the page, and could be different from what is in the address bar or what is sent in DL and DP, especially when the page is a Single Page Application (SPA). Shortcut: Clicking on the HRef will take you to the source code in the Sources tab. Similar to right-clicking and selecting View Source, but you can "Pretty Print" the source in the developer tools view.
Referrer
This is document referrer when the Inspector loads on the page. It may not be the same as seen in the GA hit in the dr parameter. Analytics.js does not include the referrer from the same domain and single page applications Notes: In Single Page Applications (SPA), this banner remains at the top, and the HRef and referrer do not change. Example: PII in HRef and Referrer: http://localhost:8000/?referrer_pii=testy.testor@gmail.com & create link https://www.foodlion.com/?page_pii=testy.testor@gmail.com
Filter
Use the Tilde (~) to exclude non-Inspector console logs. Make sure you have "All levels" selected.
Collapsed Banner
If you'd like to save space in the console, you can select "Collapse banner" in the "Control output" options. This will hide the hint and filter note.Data Layer Pushes
Anatomy of dataLayer.pushes (and other analytics calls)
Summary - console.groupCollapsed(...) The summary includes a logo, brand, object, function, key and value. If there is no event, and multiple keys, "Object - Expand for details" is displayed.
Details
Each push contains details of the push; e.g. stringified object, pointer to the push currently in memory (will not be there on the next page when preserve log is checked), and the call stack. When showing timing, it will include seconds to the thousandth, since Document Start (when the Inspector was first loaded.) Uses: See the stringified content of the dataLayer push. See evaluations when the Summary is not green. Access the Call Stack. See timing when turned on.
Object Pushed (or Arguments)
The stringified object shows the type of entity pushed to the dataLayer; (e.g. object or Arguments) and a formatted version of the entity (that will be there on the next page, when preserve log is checked, and can be copied and pasted into the console to replay). Use: See the values of the push, even from previous pages.
Currently in Memory
This is a link to the actual object in memory. The topmost line is accurate for when the object was pushed to the dataLayer. When you click on the arrow to the left of the object, (after the colon), the object will expand and an information symbol will display . This indicates that the value of the object was evaluated on the click. Notice that the event value in the top line is different from the second line. This is because the event value was modified after the push and before the click. Uses: To see what is in the dataLayer push when the object is too large or too complex to stringify.Call Stack
Links to the code that executed from the start to the console.log are shown in the expanded "Call Stack." The top links are inside the Inspector+. The bottom link is to the line of code that initiated the push. The link before function [as push], is to the code that called dataLayer.push.
Uses: Understanding where the dataLayer.push come from or what code initiated the push.
Common dataLayer pushes
These pushes are seen on every page when GTM is installed and only once per page. Gotchas: Using these events in a Single Page Application. For example, using gtm.js as a pageview in a SPA will only send a pageview when the page first loads.gtm.js
Pushed from gtm and gtag snippets. gtm.start is the time the push was made MDN - "the numeric value corresponding to the current time - the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC with leap seconds ignored." The stack is not available when the script runs before the Inspector was loaded.(function(w,d,s,l,i) { w[l] = w[l] || []; w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' }); var f = d.getElementsByTagName(s)[0], j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.defer=true; j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl; f.parentNode.insertBefore(j,f); })(window,document,'script','gdGlobals','GTM-XXXXX');Gotchas: 1. gtag and gtm pushes look different in the dataLayer, but are seen as the same in GTM. A dataLayer push from gtag with Arguments containing js and the date/time will be evaluated by GTM the same as the above event: 'gtm.js'
- Needed data in the hit that isn't there when the event triggers.
Uses: Understanding when the GTM Pageview is triggered and, when the call stack is available, seeing the code that pushes the event.
gtm.dom
Pushed from GTM when " The DOMContentLoaded event fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading." MDN . The document object is ready. Uses: When you need access the DOM.
gtm.load
"The load event is fired when a resource and its dependent resources have finished loading." MDN Gotchas: gtm.load is not a reliable event in some sites, especially publication sites, because resources may load very slowly and sometimes get blocked.
Network Hits: Anatomy of Network Hits
Summary
The summary includes a logo, brand, type and more information. Pageviews have the property ID. Events have the category, action and label (ec, ea, and el). The brand and type are color-coded with three levels: green is good, brown is worth noting and red is an error.
Parameter Definitions
GA and Adobe parameters Includes links to documentationData sent
The stringified object shows the data sent (that will be there on the next page, when preserve log is checked ). Use: See the values of the push, even from previous pages.Evaluations
General Conventions
Green Is Good
Pageview hit is valid and contains recommended CD(s)Brown Is a Notice
Pushes should have an event key: Multiple GTM containers push gtm.js Snippet not in the head, as per specRed Is Bad
Duplicate Pageviews, dataLayer resetExamples of Evaluations
DataLayer Reset
Sometimes, dataLayers are initialized incorrectly, and after data has been pushed to the dataLayer. When the dataLayer has data and is reset using syntax like dataLayer = [], and the Inspector is observing the dataLayer, you will see the following error in the console. NOTE: This evaluation can only happen if the Inspector+ is observing the dataLayer at the time of the reset. Demonstration: Inject this code into a site with a dataLayer.document.addEventListener("DOMContentLoaded",(event) => { window.dataLayer = [{stuff: 'stuffing'}] });
Ecommerce Object Data
Required structures, types and content specified by Google in the Enhanced Ecommerce (UA) Developer Guide are evaluated and, if there is a notice or error, the push will be highlighted and the details will include the reason(s).GTM Snippet Location
The GTM snippet should be installed in the HEAD element. If it is not, you’ll see a console log of a notice with a link to the script. You can click the arrow to see the script. Right-click on the script to "Reveal in Elements Panel".GTM, Optimize, and gtag Configuration Evaluated
These evaluations are in early alpha. The evaluation is done on gtm.load (when all should have been loaded). Sorting through the implementation combinations and the implications is an emerging effort.Multiple containers using the same dataLayer
Multiple GTM Containers
Controls
Inspect
On/off Auto detect dataLayer Naming the dataLayer can provide better sequencing of pushes and hitsOptions
Classic Mode
The Original Version Use: When you feel nostalgic about the simple days of Digital Analytics. JSON-ldAdd Functionality
.push({})
Pushes an object to the dataLayer (or named dataLayer; e.g. anotherDatalayer) when the Inspector+ is loaded on the page. Usually used when testing GTM and the data needs to be in the dataLayer asap. To use, add JSON formatted key (e.g. "event") and value (e.g. "dataLayer-push") pairs with colon in between, separated by commas for multiple sets.Insert GTM Container
Inserts a Google Tag Manager snippet into the page when the Inspector+ is loaded and the host is exactly what is in the Host: field, or, when RegEx is checked, the host matches the regex. Use: When you want to add a GTM container to a page. Hint: To keep the inspector dropdown window open while you go and get the GTM ID and the URL, right-click on the dropdown window and select "Inspect". Note: GTM not inserted:will be pushed to the console if the conditions for insertion do not match. Inject Code Inserts a script tag into the head. The code will run immediately upon insertion. Use: When you want to add code to the page immediately or on an event. Hint: To delay until the DOM is ready, use addEventListener; e.g.document.addEventListener("DOMContentLoaded",(event) => { // Do your stuff here; e.g. dataLayer.push… window.dataLayer.push({ event: 'example-event', stuff: 'stuffing' }) });