1

I want to send a custom dimension to google analytics to use in a custom report as per:

In some cases, you might want to send a custom dimension or metric with all the hits on a given page (or for the lifetime of the tracker object). In this case, you can set the custom dimension or metrics using the set command: ga('set', 'dimension5', 'custom data');

This is my 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','https://www.google-analytics.com/analytics.js','ga');
    ga('create', 'TRACKING-CODE', 'auto');
    ga('set', 'dimension5', 'some value here');
    ga('send', 'pageview');

My custom report looks like this: enter image description here

But I'm not getting any data e.g. some value here. Am I doing something wrong?

1

You don't have to use a Custom Variable, in Analytics go to Admin (in the bottom of the sidebar menu) > Custom definitions > Custom dimensions and add dimension5, then you will have dimension5 available to use it as a dimension in your custom report.

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.