Question

I've recently upgraded our site to use Universal Analytics and am trying to get some custom dimensions to work. However, no custom dimension data appears to be logged. Below is an example of my code.

ga('create', 'UA-XXXXX', 'test.com');
ga('send', 'pageview');
ga('set', 'dimension1', '149377');

Do I need to set custom dimensions before sending pageview?

Was it helpful?

Solution

A dimension is sent along with the either a page view or an event. It won't get sent by itself. So you should switch the order of the 'send' and 'set', then look in the network to see the page view call and you should see the dimension as one of the parameters.

Note that you will see the dimension data in google analytics with a delay of a day or so.

OTHER TIPS

I had the same problem, took me a while to find out its cause...

That's correct by the way, that is you must do the SET before the SEND.

Here is the official documentation (see section "Collection"):

[...] Unlike other types of data, custom dimensions and metrics are sent to Google Analytics as parameters attached to other hits, like pageviews, events, or ecommerce transactions. As such, custom dimension or metric values need to be set before a tracking call is made in order for that value to be sent to Google Analytics.

For example, to set a custom dimension value, your code might look like this:

ga('create', 'UA-XXXX-Y', 'auto');

// Set value for custom dimension at index 1.
ga('set', 'dimension1', 'Level 1');

// Send the custom dimension value with a pageview hit.
ga('send', 'pageview');

Cfr. https://support.google.com/analytics/answer/2709828?hl=en

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top