Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Google Analytics custom dimension using _gaq.push()

I am trying to set a GA's custom dimension in my code. I know the most straightforward way to do it would be:

ga("set", "dimension1", "1");

However, I don't have access to ga() where I want to set this dimension. As a result, I tried the following lines:

_gaq.push(["_set", "dimension1", "1"]);
_gaq.push(["_setCustomVar", 1, "dimension1", "1"]);

The first one doesn't work at all, and the second one sets a custom variable, not a custom dimension.
I cannot find any reference to an hypothetical _setCustomDimension() function in GA documentation, and nothing about dimensions in ga.js either.

Is there a solution to that?

like image 837
Pierre Espenan Avatar asked Oct 24 '25 17:10

Pierre Espenan


1 Answers

No. There are no custom dimensions in ga.js, you need to switch your property to Universal Analytics (or use custom variables instead).

I admit it's a bit confusing that alle versions of Google Analytics use the same user interface - there are some menu items that apply only to certain versions (or certain setups for certain versions).

like image 51
Eike Pierstorff Avatar answered Oct 26 '25 07:10

Eike Pierstorff