How to send custom dimensions data to Google Analytics

Discussion in 'Google Analytics' started by Hazhayder, Sep 11, 2018.

  1. #1
    Hello, I have recently setup a custom dimension in my google analytics and its index is 1 and the scope if 'User'. I am using Universal analytics implementation on my website. But i am not able to pull the report on Google analytics against my custom dimension here is my implementation code.

    <!-- Google Analytics -->
    <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', 'XXXX ID gOes here', 'auto');

    ga('send', 'pageview');
    ga('set', 'userId', '@Session["CompanyCode"].ToString()#@Session["MembersId"].ToString()'); // Set the user ID using signed-in user_id.
    ga('set', 'dimension1', '@Session["CompanyCode"].ToString()#@Session["MembersId"].ToString()');
    ga('set', 'dimension2', '@Session["CompanyCode"].ToString()');
    </script>
    <!-- End Google Analytics -->


    I am using razor view as i my application is built on asp.net mvc and i have inspected that the values goes there inside the dimension
     
    Hazhayder, Sep 11, 2018 IP