Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for ajax site! Please help with quick-and-dirty solution. #11602

Closed
UralZima opened this issue Apr 8, 2017 · 1 comment
Closed
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@UralZima
Copy link

UralZima commented Apr 8, 2017

Hello. I just published my site and installed latest Piwik 3.0.3. I used it before (versions 2) and I believe it is the best site analytics.
But my site, as many major sites uses ajax navigation, with HTML5's history.pushState method. And after posting advertising, I see 500 visitors came to my site, but I don't see anything in detail. Nothing is tracked but entry page.
I saw an issue #5159 but it is outdated and seems reported for 2.x version. The forum post not exist anymore.
I urgently need to track visitors, because site is new and errors may exist.

Please help me with some quick-and-dirty solution, in example I can call a piwik function (to change the page) inside my ajax navigation javascript function. Thanks in advance.

@UralZima
Copy link
Author

UralZima commented Apr 8, 2017

I added this code to my ajax page load function.
_paq.push(['setReferrerUrl', currentUrl]);
currentUrl = location.href;
console.log('new page loaded '+currentUrl);
_paq.push(['setCustomUrl', currentUrl]);
_paq.push(['setDocumentTitle', document.title]);
// remove all previously assigned custom variables, requires Piwik 3.0.2
_paq.push(['deleteCustomVariables', 'page']);
_paq.push(['setGenerationTimeMs', 0]);
_paq.push(['trackPageView']);

And it worked.

This page helped: https://piwik.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/

@UralZima UralZima closed this as completed Apr 8, 2017
@tsteur tsteur added the answered For when a question was asked and we referred to forum or answered it. label Apr 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it.
Projects
None yet
Development

No branches or pull requests

2 participants