Enable google analytics for single page site with # views

后端 未结 1 692
我在风中等你
我在风中等你 2021-02-06 16:51

I\'ve read the similar questions, but my question is slightly different.

I am implementing a single page registration processing page for a site using Kendo UI. The sit

相关标签:
1条回答
  • 2021-02-06 17:19

    Answer 1: Yes this will work perfectly fine: ga('send', 'pageview', '/register.html');

    You don't need the 3rd parameter if they are on the page where the code is being executed. It will automatically grab the current page where the code is being ran from if the 3rd parameter is undefined. But than this parameter allows you to set the page yourself, which could be useful if you need to send a pageview to a different page other than the page that the code is being executed on.

    change to this:

    <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-XXXXXXX-1', 'xxxxxxxx.com');
      ga('set', 'page', '/register.html');
      ga('send', 'pageview');
    </script>
    

    And in each tabs click event, add the corresponding code to track which tabs are clicked:

    Tab 1 click event: ga('send', 'event', 'tab1', 'clicked');

    Tab 2 click event: ga('send', 'event', 'tab2', 'clicked');

    Tab 3 click event: ga('send', 'event', 'tab3', 'clicked');

    Tab 4 click event: ga('send', 'event', 'tab4', 'clicked');

    Source

    0 讨论(0)
提交回复
热议问题