_pk_ref cookie


When I get a conversion (user signs up), I need to store some campaign information (name and keyword) in my own DB. Right now, I’m creating my own cookie with that information for first-time visitors and then read it out on sign-up. However, that’s wasteful because Piwik is already storing the same info in the _pk_ref cookie. Unfortunately, it’s hard to use that cookie because the cookie name includes some weird ID (_pk_ref.1.2345 for example). What’s the meaning of those numbers; how are they determined? Are they identical for all users in all browsers?

Also, what are the third and fourth value in the _pk_ref cookie?

Finally, is there any good reason for me not to use the _pk_ref cookie for my purpose?


Never mind, I figured out a decent solution: on the sign-up form, include a hidden input field for the campaign info and populate it with Javascript

   _paq.push([function() {
     var campaignName = this.getAttributionCampaignName();
     var campaignKeyword = this.getAttributionCampaignKeyword();
     if (campaignName && campaignKeyword) {
       $("#hidden_input_field_for_campaign_info").val(campaignName + "-" + campaignKeyword);

Hi Pekeler,

I have been looking for something like this also. I just wanted to know, are those AttributionCampaignName your own cookie parameters or the default ones?

Were you ever able to use the _pk_ref cookie?


I’m not fully understanding your question. getAttributionCampaignName() is a piwik function that gives you the campaign name as stored in the _pk_ref. Since I can use this function and getAttributionCampaignKeyword(), I don’t need to access the _pk_ref cookie directly.