No Data In GA And GTM Using DataLayer
I'm using Google Tag Manager and dataLayer to pull information from an eCommerce site to Google Analytics, but for the past few days the 'Add to Cart' chart has been empty, even though the test site is working fine, pulling data as it should, and I've used the same code copied across.
I can see the trigger firing in preview mode, and in live events it appears as an add to cart event but no data is showing in shopping behavior which I cannot work out.
This is the code I'm using for dataLayer:
dataLayer.push({
'event': 'addToCart',
'ecommerce': {
'currencyCode': curr,
'add': {
'products': [{
'id': pg,
'name': garmentName,
'price': garm,
'brand': 'MyStore',
// 'category': 'Apparel',
// 'position': 0,
'quantity': 1
}]
}
}
});
curr, pg, garmentName, and garm are all JavaScript variables pulled from the PHP the site runs on.
A screenshot of the tag I'm using is available here
Answer
There was nothing wrong with my code or tag, I had closed the function which contains the dataLayer push too early
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