Custom Analytics Dimension

I recently updated our site to use Universal Analytics, and try to make some custom dimensions work. However, custom dimension data is not 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 sizes before submitting a pageview?

+7
dimensions google-analytics
source share
2 answers

A measurement is sent along with a pageview or event. It will not be sent by itself. Therefore, you must switch the order of "send" and "install", then look on the network to see the call to view the page, and you should see the measurement as one of the parameters.

Please note that you will see the measurement data in Google analytics with a delay of a day or so.

+19
source share

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

This is true, i.e. , you must execute SET before SEND .

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

[...] Unlike other data types, custom dimensions and measures are sent to Google Analytics as parameters associated with other images, such as pageviews, events, or e-commerce transactions. Therefore, before making a tracking call, you must configure custom dimensions or metric values ​​to send this value to Google Analytics.

For example, to set a custom size 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

+4
source share

All Articles