Goal Tracking does not work with .php redirects?

Dear PIWIK-Team,

I use PIWIK to track the clicks on my amazon affiliate links in my blog.
I set a goal to track the outgoing clicks and everthing worked fine.

Now I replaced my amazon affiliate links with a .php file including a redirect with my amazon affiliate link. So my visitors click on myblog.com/productname.php and will be redirected to my amazon link.

Since then my goal tracking does not work anymore. Of course I created a new goal with the .php file as a url in it.
I also tried “external link” and “internal website” as goal.

any ideas?

best wishes
Max

Funny but I have exactly the same problem. I use .com/visitid123 to redirect visitors to my affiliate links and it seems that piwik doesnt track goals. I tried many configurations but without any success. How to solve this issue?

Because the “link hostname” belongs to current site, it will not be tracked as “outlink”.

I agree we should make your particular use case easy…

Onesolution would be to call trackGoal() function on the click even as explained with trackPageView() here: http://piwik.org/docs/javascript-tracking/#toc-manually-trigger-a-page-view-on-click-or-on-js-event

Alternatively you can try to force the click to be recorded as outlink with this technique: http://piwik.org/docs/javascript-tracking/#toc-force-a-click-on-a-link-to-be-recorded-as-an-outlink

Does it help?

Dear matt,

thanks for your quick reply.

I tried both of your linked methods unsuccessfully.

I added this code:


<a href="http://mywebsite.xx/amazonlink.php" onclick="javascript:piwikTracker.trackPageView('amazonlink.php');">Link Text</a>

But I does not show any tracking of the .php file in PIWIK neither a goal conversion.

Any Ideas? Maybe I need to add some PIWIK Code to the PHP file?

best wishes

Max

Sorry I meant try something like


onclick="javascript:piwikTracker.trackGoal(1);"

Hey Matt!

Thank you for your help. Unfortunately, I cannot get it work properly. I used this:


<a href="'.home_url().'?shortlinks='.$post->ID.'" target="_blank" onclick="javascript:piwikTracker.trackGoal(1);">Link Text</a>

then in PIWIK, created a manual goal “1” with following selected: “Click on a Link to an external website” and “Allow Goal to be converted more than once per visit”.

I click on those links, and PIWIK does not track them. What am I doing wrong?

UPDATE: Everything works great now. My mistake, I was using wrong Goal ID. Why Goal ID is not displayed while creating a goal? It can be found only when Editing Goals. I think this is confusing for less technical people. :slight_smile:

I tried it with the new code…


onclick="javascript:piwikTracker.trackGoal(2);"

and chose “Click on a Link to an external website” and set the URL to “is exact” mywebsite.xx/redirect-file.php. ID of the goal is 2.
It still doesn’t work :frowning:

[quote=MaxLove]
I tried it with the new code…


onclick="javascript:piwikTracker.trackGoal(2);"

and chose “Click on a Link to an external website” and set the URL to “is exact” mywebsite.xx/redirect-file.php. ID of the goal is 2.
It still doesn’t work :([/quote]
I presume you left “when visitor triggers” on. You must choose “Manually” under the “Goal is triggered”. So, Edit ID 2 goal, set to manually, update and it should work perfectly.

BTW, Piwik is absolutely awesome! Loving it, especially the “Visitors Log”, it shows so much of valuable information. Google Analytics cannot compare to this. Great job! Thank you Piwik Developers! Keep up the good work.

Thanks glad you got it working!

[quote=looox]

[quote=MaxLove]
I tried it with the new code…


onclick="javascript:piwikTracker.trackGoal(2);"

and chose “Click on a Link to an external website” and set the URL to “is exact” mywebsite.xx/redirect-file.php. ID of the goal is 2.
It still doesn’t work :([/quote]
I presume you left “when visitor triggers” on. You must choose “Manually” under the “Goal is triggered”. So, Edit ID 2 goal, set to manually, update and it should work perfectly.[/quote]

I tried this but I still does not work…

Hello everyone,
I had a similar problem, and that solution with the “Force a Click on a Link to be Recorded as an Outlink” worked nicely for me, I’ve added the ‘piwik_link’ class to links and all goals are now counting :slight_smile: Thank you so much!