[RESOLVED] Change URL to track via javascript


#1

I am using PIWIK to track events along side the site. I have some ajax actions that I am attempting to track by using the following method inside the js function:

_paq.push([‘trackPageView’, ‘Event/Crime/’ + crimeid]);

This wirks great, but whatever the page the user is on when clicking this is the URL reported in PIWIK.

I want to set it to something similar to this:

http://domain.com/Event/Crime/{CRIME_ID}

But I cannot see how to do this. I am following the wiki here:
http://developer.piwik.org/api-reference/tracking-javascript

I just cant seem to find how there.


(Matthieu Aubry) #2

You can use setCustomUrl( customUrl )


#3

Hmm… I get this when attemptiong that:

Uncaught ReferenceError: setCustomUrl is not defined

function doCrime_js(crimeid) {
$("#crime_results").html(“It takes you a minute to do the crime…”);
$.get(“docrime.php?c=”+ crimeid, function(data) {
$("#crime_results").html(data);
setCustomUrl(‘http://domain.com/Event/Crime/’ + crimeid);
_paq.push([‘trackPageView’, ‘Event/Crime/’ + crimeid]);
refreshUserData();
});


#4

Solved it:

function doCrime_js(crimeid) {
$("#crime_results").html(“It takes you a minute to do the crime…”);
$.get(“docrime.php?c=”+ crimeid, function(data) {
$("#crime_results").html(data);
_paq.push([‘setCustomUrl’, ‘http://domain.com/Event/Crime/’ + crimeid]);
_paq.push([‘trackPageView’, ‘Event/Crime/’ + crimeid]);
refreshUserData();
});
}

thanks for your help!