lk1234
lk1234

Reputation: 113

Single page analytics tracking

I am new to GOogle Analytics. I have a single page site. It has multiple tabs that are reflected in the URL. Main url is index.html and if you switch to a different tab the URL becomes index.html?FaqPage

Is there a way to setup Google Analytics to give analytics on all the tabs seperately? I tried

ga('send', 'pageview', '/index.html');

But the analytics only seem to track index.html and not any of the ther URLs. Also tried the following (with proer tracking code) but doesnt seem to work:

    ga('create', 'UX-xxxxxxx-x', 'auto');
    ga('set', { page: '/index.html?FaqPage', title: 'Faq'}, { page: '/index.html?MemberPage', title: 'Member'});
    ga('send', 'pageview');

Upvotes: 1

Views: 51

Answers (1)

nyuen
nyuen

Reputation: 8907

You're on the right track. One solution is to send a virtual pageview whenever a tab is clicked:

ga('send', 'pageview', '/faqpage')

And do similarly for all your tabs. Here is some more info https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications.

Upvotes: 1

Related Questions