Piwik: ¿extraer idvisitor de una cookie de terceros?

How does Piwik encode a visitor ID in a _pk_uid third-party cookie?

I am a new Piwik user attempting to track users across domains. I found a section of the Piwik FAQ that seemed promising: http://piwik.org/faq/how-to/#faq_118

It says that when I enable third-party cookies, Piwik will create a third-party cookie containing a unique ID for a visitor that is the same as the idvisitor field of some of the MySQL tables.

The trouble is that I can't seem to figure out how idvisitor is encoded within the third-party cookie (named _pk_uid, anteriormente piwik_visitor I think) --and, in fact, I am skeptical as to whether it actually is contained in the cookie!

Here's the value of the cookie I am looking at:


And the visitor ID that is supposed to be contained within is:


preguntado el 29 de junio de 12 a las 20:06

3 Respuestas

So this is my observation from my own site.

  1. The number before first dot is user_id(_id)
  2. Next, there is UNIX timestamp of the time of the first visit by this visitor.(_idts)
  3. 5 is the current count of visits for this visitor.(_idvc)
  4. I guess this is UNIX timestamp of last action on site.
  5. The UNIX timestamp of the time of the previous visit by this visitor.

Here is the example from my site. First there is the cookie and than there are parameters sent by piwik script.



Respondido el 28 de Septiembre de 13 a las 09:09

Although a little outdated, but since I'm currently looking for that - As far as I can deduct (not 100% sure) you first need to convert to cookie to hexadecimal and then from base 16 to base 10.

Respondido 11 Feb 13, 11:02

This is how I get the visitorId in PHP:

$cookieArray = explode(":", $_COOKIE['_pk_uid']);
$visitorIdArray = explode(":",base64_decode(substr($cookieArray[0],2,31)));
$visitorId = str_replace('"','',$visitorIdArray[2]);

Respondido el 18 de diciembre de 15 a las 20:12

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.