sk_ad
January 10, 2012, 9:06am
1
At this time, there seems to be no way to explicitly set the visitor ID using the JavaScript Tracker API (see my other post at 301 Moved Permanently ). It would be great for us to have a means to do so in order to correctly track visitors in an intranet setting.
The feature suggested may work like this:
Currently, our visitors are tracked using the following code snippet:
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.mydomain.com/piwik/" : "http://www.mydomain.com/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://www.mydomain.com/piwik/piwik.php?idsite=1&cid=0123456789abcdef" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->
Using the CID request parameter in the image tag allows us to explicity set a visitor ID. We use this feature to correctly identify and therefore count intranet users by generating these IDs from the user names given after they log in to our site. However, it is not possible to use this mechanism in the JavaScript tracking code. I would expect something like this to work:
piwikTracker.setVisitorId("0123456789abcdef")
or adding the CID to the
Piwik.getTracker(...)
method as request parameter.
vipsoft
(vipsoft)
January 11, 2012, 3:07am
2
Use piwikTracker.setCustomVariable(1, ‘cid’, ‘01234567890abcdef’ ) ;
sk_ad
January 25, 2012, 9:57am
3
Hello,
unfortunately not. It seems that the CID ist not set using the following snippet:
<script type="text/javascript">
/*<![CDATA[*/try{var piwikTracker=Piwik.getTracker(pkBaseURL+"piwik.php",1);
piwikTracker.setCustomVariable(1,"cid","8b49cc49bcb5ee21");
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking()}
catch(err){};/*]]>*/
</script>
The configuration file has been changed as suggested. When appending the CID as request parameter to the embedded image URL, it works fine.
Best regards,
Sebastian
matthieu
(Matthieu Aubry)
January 25, 2012, 10:04am
4
Please replace piwikTracker.setCustomVariable(1,“cid”,"8b49cc49bcb5ee21"winking smiley;
by piwikTracker.setCustomData(“cid”,“8b49cc49bcb5ee21”);
does it work then?
sk_ad
January 25, 2012, 10:06am
5
Thanks for the suggestion, I’ll check this.
sgoker
March 27, 2012, 10:37am
6
I have a similar problem about setting the visitor ID explicitly. I ve tried
_paq.push(['setCustomData','cid','0123456789abcdef']);
_paq.push(['setCustomVariable','1','cv1','cv1dat','visit']);
_paq.push(['setCustomVariable','2','cv2','cv2dat','visit']);
_paq.push(['setCustomVariable','3','cv3','cv2dat','page']);
and seen that the when i changed cid value, there is no difference on “idvisitor” and “idvisit” fields.
Any idea?
matthieu
(Matthieu Aubry)
October 30, 2012, 4:04am
7
Thanks for the suggestion, I created a ticket: Accurate User Detection cross devices: User ID (set in JS and all other clients) · Issue #3490 · matomo-org/matomo · GitHub
I hope we will work on it soon. If you can sposor some work on it please get in touch that would be great and would help!
I’ve temporarily solved the problem using the function ‘appendToTrackingUrl’:
_paq.push(["appendToTrackingUrl", "cid=1234567890111111"]);
In the file config.ini.php I’ve added these two lines:
[Tracker]
tracking_requests_require_authentication = 0
I’m tuned on #3490 !! (:P)
matthieu
(Matthieu Aubry)
September 8, 2014, 4:37am
9
In Piwik 2.7.0 beta+ there was a change: Tracker API: cid parameter no longer requires token_auth #6109
opened 12:46AM - 03 Sep 14 UTC
closed 04:35AM - 08 Sep 14 UTC
Major
Enhancement
c: Security
The goal of this ticket is to modify the tracker API so that the `cid` parameter… should no longer require to use the token_auth.
Tasks:
- modify tracker API
- update the reference docs http://developer.piwik.org/api-reference/tracking-api as well as any FAQ or user guide that may mention `cid`.
This overall goal is to make Mobile Apps Tracking easier to use and less need of configuration in the SDK. See also: #4994, Android SDK: #4733 and [iOS SDK](https://github.com/piwik/piwik-sdk-ios)