Grin
Grin

Reputation: 577

Custom dimensions don't work in GA universal on web

I use this code on the website:

<script>
  var ga_global_dims = {"ab_product_page":"productpagev2"};
</script>
	
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  
  ga('create', 'UA-58015409-1', 'auto');
  ga('set', ga_global_dims);
  ga('send', 'pageview');
</script>

I also added this dimension in property settings: enter image description here

However I don't see any data when using this dimension in segments. I need to see the amount of traffic and events with this dimension.

What am I doing wrong?

Upvotes: 0

Views: 123

Answers (1)

Eike Pierstorff
Eike Pierstorff

Reputation: 32760

In your set call do not use the name of the dimension - instead you have to use the string "dimension" suffixed by the numeric index of your custom dimension:

<script>
  var ga_global_dims = {"dimension1":"productpagev2"};
</script>

All values are transfered via the url of the tracking pixel. If Analytics had to transfer the name of each dimension the maximum length for the url would be exceeded if you have many custom dimensions with long names. Using the index means the dimension can be transmitted using a very simple parameter ("&dim1").

Plus it might take a while (longest I have experienced where some 48 hours) before values for custom dimensions show up.

Upvotes: 1

Related Questions