How to extract idvisitor from third-party cookie? (was: Cross-domain tracking with different tracking code? And how to connect with another service?)

Old question quoted, but please see post 3 below

[quote=Lochlan]
A two-part question:

I would like to have multiple domains with different tracking code that can track an individual user across domains. (Also–not sure if this is relevant–I want to have the tracking IDs connected to separate user accounts.)

So, for example:

www.domain1.com <-- Piwik tracking ID 1
www.domain2.net <-- Piwik tracking ID 2

So let’s say that User A visits domain1.com and then goes to domain2.net. How do I track that one user across these two domains? I think it might have something to do with segmentation??

I have an online service that someone logs into (let’s say it’s at domain1.com), how do I associate the user’s username with the tracking–and then, how do I associate that username with tracking accross domain1.com and domain2.net? (I.e. User A logs in to domain1.com, then later goes to domain2.net–how do I identify them, so that I can report on metrics related to logged-in users visiting my different domains?)

(And I am a programmer, I am not afraid to dig into the API, create some cookies, etc.–I don’t necessarily need an out-of-the-box solution, just for someone to point me in the right direction.)

Thank you![/quote]

Nevermind, I found what I was looking for in the FAQ. (Sorry, I couldn’t find it the first time I looked!)

http://piwik.org/faq/how-to/#faq_118

OK, so, I enabled the _pk_uid cookie (via use_third_party_id_cookie = 1) – how do I extract the visitor information from the cookie?

The FAQ says: When this is enabled, Piwik tracker will serve a third party cookie containing an id visitor (16 chars ID). This ID will be the same for this visitor across all websites, and is stored in the database field “idvisitor”.

Here is the value of the cookie:
0%3DczoxNjoiMmMwMWY5OGU0MzFkNWQxOSI7%3A_%3Df6f84dfd6626b538220696bb070d22f8ae2af6ee

The idvisitor is 2c01f98e431d5d19 (in hex, or 3171090002052209945 in decimal), but I can’t seem to find this string within the cookie.

How is idvisitor encoded in the cookie?

Thank you!

EDIT: So, actually, I think idvisitor is stored in a cookie called _pk_id.1.4cee ?? I’m pretty confused. What is _pk_uid for then? How does idvisitor relate to the cookies? Any advice or guidance is greatly appreciated.

There might be a bug in the code. Can you try the following: How to - Analytics Platform - Matomo

This will force piwik to trust the ID in the cookie. Then maybe the ID will be set correctly in the DB as per the 3rd party cookie.

Please comment here if it works or if it still does not work, I will investigate then!