Quantcast
Channel: Piwik Forums - Support & Bugs
Viewing all articles
Browse latest Browse all 4243

Using API for special URLs in relation to JS page tracking dublicates visits on some browsers. (no replies)

$
0
0
Hi,
I have a script that generates file download urls and have inserted the needed code there to send to piwik that information and count it as a download.
I am able to track those downloads fine. The problem is a little wierd.

The user visit gets counted normaly by piwik using either the js or img part of the tracking code. But if the same user the next moment hits the download button that will power-up the downlaod script I mentioned, then instead of seeing piwik adding the "download" to that user's actions on the stats, it opens a completely new line, using the same IP of the user and browser info, and adds the "download" there. That would not be a problem if the visit number would not change as well -- yes the download gets counted as a new visit by the same IP and not just as a download action of the same visitor.

What complicates things is that on IE everything works as expected.

I will include the code I use in a moment.
Any help appreciated.

EDIT:
This is the php code I use in the download script:
require_once(LIBS.'stats/PiwikTracker.php');
PiwikTracker::$URL = STATS_URL;
if (!isset($stats)) { $stats = new PiwikTracker(PIWIK_SITE_ID, STATS_URL); }

$stats->setTokenAuth(PIWIK_TOKEN_AUTH);
$stats->setIp( get_ip() );
$stats->doTrackAction(BASE_APP_URL.$filename, 'download');

if ($referer = referer())
{ $stats->setUrlReferrer($referer); }

if ($user_agent = user_agent())
{ $stats->setUserAgent($user_agent); }

$stats->doTrackGoal(PIWIK_SITE_DOWNLOAD_GOAL_ID, PIWIK_SITE_DOWNLOAD_GOAL_REVENUE); // $idGoal, $revenue

Notice in the screenshot. although I hided the IP, it is the same visit, counted as 2 visits.


Another example with Google Chrome:


Now see how it all works just fine when the visit is from IE:



If there is one thing I can notice, this is that on other browsers other than IE (maybe more I haven't tested), the download shows "Direct Entry". For some reason this doesn't appear on IE. As I mentioned this is a download "button" and not a href link for the file.
Anybody has an idea how to make this not split the visit into 2 ?
Any help appreciated.

Viewing all articles
Browse latest Browse all 4243

Trending Articles