Note that there are some explanatory texts on larger screens.

plurals
  1. POEnable google analytics for single page site with # views
    text
    copied!<p>I've read the similar questions, but my question is slightly different. </p> <p>I am implementing a single page registration processing page for a site using Kendo UI. The site has 4 pages which was generated dynamically when user clicks menu tabs. For example, when user clicks tab1 on the menu, then <code>tab_1</code> would be injected into <code>app_container</code> container.</p> <p>templates as below: </p> <pre><code>&lt;div id="app_container"&gt;&lt;/div&gt; &lt;script id="tab_1" type="text/x-kendo-template"&gt; //first page &lt;/script&gt; &lt;script id="tab_2" type="text/x-kendo-template"&gt; //second page &lt;/script&gt; &lt;script id="tab_3" type="text/x-kendo-template"&gt; //third page &lt;/script&gt; &lt;script id="tab_4" type="text/x-kendo-template"&gt; //fourth page &lt;/script&gt; </code></pre> <p>The page is under the domain: <code>www.xxxxxxxx.com/register.html</code>.</p> <p>when user clicks the tabs in menu, then the http link address changed to this: <code>www.xxxxxxxx.com/register.html#/p1</code></p> <p><code>www.xxxxxxxx.com/register.html#/p2</code></p> <p><code>www.xxxxxxxx.com/register.html#/p3</code></p> <p><code>www.xxxxxxxx.com/register.html#/p4</code></p> <p>I've grabbed the code from GA:</p> <pre><code>&lt;script&gt; (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('send', 'pageview'); &lt;/script&gt; </code></pre> <p>1) Question1, as I just only like to track this registration page, I've read google's documentation, <a href="https://developers.google.com/analytics/devguides/collection/analyticsjs/pages" rel="nofollow">developers.google.com/analytics</a>,will this codes work?</p> <pre><code>ga('send', 'pageview', '/register.html'); </code></pre> <p>2) Question2, how to enable GA to get data for 4 different tab pages? Do I have to modify onlick actions to track the event? or just simple track the anchor tag? I've read something from <a href="http://tizardsbriefcase.com/716/javascript/google-analytics-for-tracking-hash-urls" rel="nofollow">Tracking Hash URLs</a>, will this codes work for my situation? As it may take some time to show analystic, can't test it now: </p> <pre><code>_gaq.push(['_trackPageview', "/" + window.location.hash]); </code></pre> <p>where shall I put this line of code to if it is working for this single page application?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload