Search code examples
cookiesmatomo

Piwik: extracting idvisitor from thirdparty cookie?


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, formerly 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:

0%3DczoxNjoiMmMwMWY5OGU0MzFkNWQxOSI7%3A_%3Df6f84dfd6626b538220696bb070d22f8ae2af6ee

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

2c01f98e431d5d19

Solution

  • 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.

    _pk_id.19.c40d=baa767bdf0dfe66d.1379976944.5.1380357406.1380061476.;
    
    _id:baa767bdf0dfe66d
    _idts:1379976944
    _idvc:5
    _viewts:1380061476