0

Sorry for this very basic question but I can't figure it out.

On my website I'm moving from Google Analytics to Piwik. I got Piwik working however, I can't trigger a pageview.

The main problem is that a page is loaded by javascript and ultimately being pushed to with a history.pushstateto the address bar.

For tracking with Google Analytics I could push it as easy as ga('send', 'pageview', page); But I can't find the same for piwik.

Any help is much appreciated.

JeroenED.

1 Answer 1

0

I'm wrestling with Piwik, too. Afaik, the most reliable way to talk to Piwik is through its global _paq variable. Track a page view like this:

_paq.push(['trackPageView']);

However, Piwik does not seem to track a page view for the current URL, but rather for the URL it saw when it booted. So you'll need to update Piwik with the new URL before tracking another page view:

// Some history.pushState({}, title, url) here …
_paq.push(['setCustomUrl', url]);
_paq.push(['trackPageView']);

You might want to set the document title (setDocumentTitle) as well. Find an overview of Piwik's JS API here.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .