Google Analytics Custom dimension doesnt work

2 replies
  • SEO
  • |
Hello,


I'm having some troubles with the custom dimension that i set in my file's header. The analytics is linked to my site because i get on the analytics the real time count.

That been said, as you can see in the code there is a JS variable iduser it contains the value of a div that has the current ID of the user connected.

I created the dimension based on Hit so i make some interactions in my page but i don't get the value of userid in my custom reports

I was wondering if some of you can help and tell me where my set up is wrong ?


NOTE: The name of the dimension in my GA is : dimension1
Code is below.


Thank you so much in advance


(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');

iduser = $('#userid').text();

ga('create', 'UA-xxxxxxxxxxx', 'auto');
ga('set','dimension1', iduser);
ga('send', 'pageview');
#analytics #custom #dimension #google #work
Avatar of Unregistered
  • Profile picture of the author savidge4
    Originally Posted by kurosaki4d View Post

    ga('create', 'UA-xxxxxxxxxxx', 'auto');
    ga('set','dimension1', iduser);
    ga('send', 'pageview');[/B]
    Look here: https://developers.google.com/analyt...stom-dims-mets your syntax for the above section is not correct.

    Should look something like:

    Code:
    ga('send', 'pageview', {
      'dimension1':  'My Custom Dimension'
    });
    Signature
    Success is an ACT not an idea
    {{ DiscussionBoard.errors[11409851].message }}
    • Profile picture of the author kurosaki4d
      Thank you for your answer.

      I changed my code as requested !

      ga('create', 'UA-xxxxxxxx', 'auto');

      ga('send', 'pageview', {

      'dimension1': '222222222'

      });


      I did use the Google Analytics Debugger. However, it does display the custom dimension as you will see in image link provided : Link to the image (Debugger)

      Currently i am in need of just one Custom dimension which is the User ID


      I don't understand why this does not work, is there a syntax problem ? Because the Custom dimension shows up in the debugger, the tracking is shown in real time GA. What might be blocking the data ???

      https://i.imgur.com/9Tfgehj.jpg

      {{ DiscussionBoard.errors[11414778].message }}
Avatar of Unregistered

Trending Topics