DTM Examples- General Troubleshooting and Common Code Snippets

Note: These snippets only work on the original DTM, not DTM Launch. For tips on using Launch, see the super-helpful Jim Gordon's Launch Cheat Sheet.


You can use most of these snippets on this page to see working examples.

See or download our various partner debugging plugins.


Use this snippet in the console: To do this:

_satellite.setDebug(true)

Enable debugging without the switcher plugin

_satellite.settings.isStaging

Determine if you're currently looking at a page with the staging or production library

localStorage.setItem('sdsat_stagingLibrary', true)

Use your staging library on a production page (after page reload)

localStorage.setItem('sdsat_stagingLibrary', false)

Go back to default library (after page reload)

_satellite.buildDate

Know how recently your library was published

document.querySelectorAll("css tag here")

See what elements on the page match a CSS Selector tag, without using jQuery. Helpful for Event-Based Rule conditions. For example: document.querySelectorAll("a.partners")

_satellite.getVar("data element name")

Return the value for a data element on the current page (case sensitive). For example: _satellite.getVar("Content: Page Name")

digitalData

Return the W3C data layer on the current page- obviously, this only applies to pages WITH a W3C data layer.

_satellite.track("DCR condition")

Run a Direct Call Rule from the console (case sensitive). For example: _satellite.track("basic page")

s.t()

Fire a beacon with all currently-set variables (only works if "s" object is globally scoped)

_satellite.pageBottom()

Run page-bottom page-load rules and tools again




Use this snippet: In this location in DTM: To do this:

_satellite.notify("message",1)

Custom Code Blocks within DTM

Send a message from DTM custom code blocks to the console log. Only works when debugging is enabled. The second argument is a number that indicates priority, 1 being low priority, and 5 being highest (this page shows examples of priorities, if you look at DTM debugging). Use this instead of console.log() to keep the console cleaner, and to prevent possible issues in older browsers.

s = new AppMeasurement(); In your Analytics Tool Library (AKA s_code)

Define your "s" object globally- get details and example

document.body.appendChild() Custom Code Blocks within DTM

Set a third party tag after pageLoad- get details and example.

if(_satellite.settings.isStaging==true){return "staging: "+_satellite.buildDate}else{return "production: "+_satellite.buildDate} A custom code Data Element

Create a data element that returns whether the current beacon came from the staging or production library as well as the library publish date (example: "staging: 2016-01-19 14:37:56 UTC") .