Ad
What's Wrong With My Variable Definition In Google Tag Manager?
I have pushed some values into the dataLayer as you can see below, I have them on google tag manager debugging console:
I have defined a custom javascript variable like this:
function() {
var dest;
dest = google_tag_manager[{{Container
ID}}].dataLayer.get("DestinationLocation").fromLocation;
return dest;
}
but still, it's undefined in the variable list.
Ad
Answer
You are trying to get a reference to the tag manager object, and while this works in tags it does not work in variables.
There is no reason why this should work - if the value is on the dataLayer (either via a push, or via the datalayer.set method) you can just create a dataLayer variable that will return the value. No need for any custom scripting.
Ad
source: stackoverflow.com
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM
Ad