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

how to use setGenerationTimeMs() with angularJS? #11968

Closed
wei1215583760 opened this issue Aug 18, 2017 · 3 comments
Closed

how to use setGenerationTimeMs() with angularJS? #11968

wei1215583760 opened this issue Aug 18, 2017 · 3 comments
Labels
answered For when a question was asked and we referred to forum or answered it.

Comments

@wei1215583760
Copy link

I have read this blog to track single-page website, but i do not know how to use setGenerationTimeMs() to track new page view generation time with different url and where these code should it be placed in the index.html? Should it be located before piwik traditional tracking code ?
@Sija @nbezzala
if you can reply, i will be grateful your for help

0b1fa1c386f3b04b97c4439fff75f333

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

@sgiehl
Copy link
Member

sgiehl commented Aug 18, 2017

@wei1215583760 would you mind asking your questions in our forum: https://forum.piwik.org
This is an issue tracker and should be used for reporting bugs or suggesting new features, not for asking questions.

@wei1215583760
Copy link
Author

wei1215583760 commented Aug 18, 2017

Piwik also supplies method to solve this problem as follows:
https://piwik.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/

But I just do not know where to place these code
var currentUrl = location.href;
window.addEventListener('hashchange', function() {
_paq.push(['setReferrerUrl', currentUrl]);
currentUrl = '' + window.location.hash.substr(1);
_paq.push(['setCustomUrl', currentUrl]);
_paq.push(['setDocumentTitle', 'My New Title']);

// remove all previously assigned custom variables, requires Piwik 3.0.2
_paq.push(['deleteCustomVariables', 'page']); 
_paq.push(['setGenerationTimeMs', 0]);
_paq.push(['trackPageView']);

});

and how to measure generation time with different url of single-page website

@sgiehl
Copy link
Member

sgiehl commented Sep 10, 2017

It depends on your usage of AngularJS and how pages are loaded. I would include that JS right after the JS that loads new page content. The generation time needs to be calculated by your JS and needs to be set for _paq.push(['setGenerationTimeMs', 0]);

But as mentioned: Please ask further questions in our forum or get in touch with professional support.

@sgiehl sgiehl closed this as completed Sep 10, 2017
@sgiehl sgiehl added the answered For when a question was asked and we referred to forum or answered it. label Sep 10, 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