0

I'm making a website in Python Django and I'd like to add my a custom variable (dimension with user level scope) to my Google Analytics. So, I created directions in creating one from this GA instructions page, yet my custom variable is not being tracked in my dashboard. I can see it in Reporting > Audience > Custom > Custom variables. The dimension is available for me to add as a secondary dimension (although strangely not as primary dimension - or is it auto selected because I have just one custom variable and the primary dimension in the table is auto selected as 'Custom Variable (Key 1)'?)

Why am I not getting any data for my custom variable? I'm supposed to be getting the registered user's email. I've tried user.email and user.user.email and one of them should've worked for my site, but neither are capturing data. I can see the traffic being recording in real time as I reload a page, so code is fine, hits are being sent and recorded. Is my custom variable wrong? Did I overlook something in defining it? Or is there some 24 hour window for me to see custom variable data?

It's my first time, help much appreciated!!

  (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','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-XXXXXXXX-1', 'auto');

  var dimensionValue = "{{ user.email }}";
  ga('set', 'dimension1', dimensionValue);

  ga('send', 'pageview');

My custom variable definition: enter image description here

My Reporting dashboard allows me to select user_email as secondary dimension, but shows no data. enter image description here

1

Your screenshot shows the report for Google Analytics custom variables, however your code is for custom dimensions.

Custom variables where a feature in the previous incarnation of Google Analytics, tracked via the now deprecated ga.js library. They had their own report in the GA interface which is still present, since the interface is a "one-size-fits-all" kind of thing and if you have custom variables that you have collected in the past you still want to be able to access them.

Custom dimensions are supported by Universal Analytics, the current version of GA. They have taken the place of custom variables, which are no longer supported by the tracking code.

You can completely ignore the "Custom" menu item in the GA interface - the only people who need that are people who want to look at custom variables they collected with legacy code.

Custom dimensions do not have their own report, you can select them as secondary dimensions in your standard reports or create custom reports with a custom dimension as primary dimension (and you can use them for segmentation).

  • I put: console.log(dimensionValue); in my script and my chrome console prints out my email address- the correct value of 'dimensionValue'. So Django is sending the correct value to my script which assigns it to the correct variable. So, if my GA code is correct, which you think it is (feel free to double check), it is sending my email as the value of my custom dimension. Either GA is not processing it or I'm not able to find it. See new screenshot for when I tried segmentation - the dimension exists but has no values. – Dr Confuse Dec 14 '16 at 5:17
  • Am I still not looking at the right place or is there some issue with the processing? The correct value(s) that should be displayed for the dimensionValue is my full email address: " yxxyxy.xy###@gmail.com " – Dr Confuse Dec 14 '16 at 5:17
  • Does GA, not process email addresses or something like that? – Dr Confuse Dec 14 '16 at 5:19
  • Or if I'm still not looking at the right place, could you please be more specific about where I should be looking to find the values of this dimension. A screenshot would be much appreciated. – Dr Confuse Dec 14 '16 at 5:20
  • Here is my screenshot of no values for this Dimension: lh3.googleusercontent.com/… – Dr Confuse Dec 14 '16 at 5:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.