Jefferson Ribeiro
Jefferson Ribeiro

Reputation: 13

How to send custom dimension via gaEvent using datalayer

So I'm trying to fire a gaEvent passing some custom dimensions but I'm not sure how its done using GTM.

This code snipped below dispatch the gaEvent but when I inspect to see if the custom dimension was sent, it isn't shown in the 'custom dimension' tab of the tagmanager preview

gtm_dataLayer.push({
                'event': 'gaEvent',
                'gaEventCategory': category,
                'gaEventAction': action,
                'gaEventLabel': label,
                'gaEventValue': value,
                'gaDimension8': 'test'
            });

Upvotes: 0

Views: 770

Answers (1)

kgrg
kgrg

Reputation: 1633

With your current code you have sent the data into dataLayer. However, you need to be sure, that it is passed with the Universal Analytics tag. To do so, you need two things.

  1. Create a new data layer variable among GTM variables, where you reference your variable. Please note, that at this point you could even use a more descriptive variable name (e.g. eventRelevantData). However, at this point you should refer to gaDimension8 variable.

enter image description here

  1. Set the event tag to use this newly created variable. You need to open the More settings block of your tag, and look for Custom Dimensions. Here, you need to provide the index (8 in your case), and a reference to your newly created variable.

enter image description here

Also, please make sure, that the variable is created and enabled in Google Analytics.

Upvotes: 1

Related Questions