Laurent
Laurent

Reputation: 1563

Google Tag Manager - custom event - category is undefined

I have started using Google Tag Manager recently and I don't understand why one of my variables remains undefined while everything seems to be set up correctly.

Here is first the code that I use to create my datalayer:

<script>
  window.dataLayer = [{
    'pageCategory': 'test1',
    'Device' : 'test2',
    'Manufacturer': 'test3'
   }];
</script>

I have created custom dimensions based on those variables and I can find them in Google Analytics. So far, everything is all right.

I then want to track a click on a button that leads the users to an external link. I use the following code:

window.dataLayer.push({
  'ShopURL': url,
  'ShopName': shop_name,
  'PriceOffer': price,
  'event': 'ClickPrice'
});

I have checked the content of each variable with a console.log and they all display the correct values.

In GTM, I have created datalayer variable for each one of them, I have created a custom event to push them to Google Analytics. I have taken "ShopName" for event_category, "Device" for event_action, "PriceOffer" for event_label.

When I look at the data in Google Analytics I see that event_category is undefined while event_action has the correct value. It looks like the event is fired correctly because I can only see it in GA when I click on the button but somehow some variables are not populated correctly.

You can see it in action here: https://www.mobilemultimedia.be/en/nokia/price-nokia-8.1 (click on one of the "check offer" button to trigger the event)

With GTM preview in the browser I see all the correct values.

Any idea?

Additional info Here is a screenshot of the variable configuration in GTM: enter image description here I'm sorry, it's in French but you can see the variable with the right name.

Upvotes: 1

Views: 1633

Answers (1)

XTOTHEL
XTOTHEL

Reputation: 5208

I believe you have your trigger set incorrectly.

enter image description here

I think it might be an element click trigger right now, but you need it to be a "custom event" trigger and you should have "ClickPrice" as the event name you use to trigger.

Like so:

enter image description here

Upvotes: 1

Related Questions