Goal conversion with PHP on file download - help please!


So far Piwik is great and easy and all things nice, but I am having a spot of trouble with goal conversions for a download link using PHP image tracking. The goal is being triggered for every visit to the page, not the actual download only.

Normal page tracking is working 100% with this code:

require_once "PiwikTracker.php";
PiwikTracker::$URL = 'http://mysite.com/piwik/';
echo '<img src="'. str_replace("&","&", Piwik_getUrlTrackPageView( $idSite = 4, $customTitle = 'pagetitle')) . '" alt="" />';

Now I want to track a download link on the site, so I add:

echo '<img src="'. str_replace("&","&", Piwik_getUrlTrackGoal( $idSite = 4, $idGoal = 1)) . '" alt="" />';

Where Goal ID 1 settings looks like this:

Where am I missing the boat?

The implementation is here:

Looks good, it should work, what is the generated URL ?

does your conversion not show up in the Real time or Visitor log ?

Thanks Matt,

The problem is more that conversions ARE showing up everywhere as false positives. I have since realised I made a mistake in the RegEx of the ‘Where filename is’ section in Piwik. I forgot to escape the second ‘.’ of the filename extension.

Also, I was including the PHP goal code on every page. I have changed that to be only on the relevant page.

I am now monitoring if it works, but traffic to my site is slow today.

It is still feeding out false positives on the download page. Here is what my Goal settings look like now: