Extend pk_id cookie with sever side gtm

Hi,

Would like to get your thoughts on this. I’d like to prolong the life of the pk_id cookie.

And do so using the cookie monster tag in Google tag manager server side we can store the pk_id cookie value in a custom created server side cookie. Lets call it the “backup cookie”. We can then overwrite the real pk_id cookie using the cookie monster tag and the backup cookie value if the value in the real pk_id doesnt exist or isn’t correct.

What do you think? would it be possible? does the pk_id name or value change over time somehow?

Hi @dandan,

Here is a link to our documentation on pk_id: Cookies created for visitors by Piwik PRO | Data and cookies | Piwik PRO help center
And value does in fact change over time, for example with each visit the visitsCount goes up in the cookie. Those parts of the value change dynamically as well: currentVisitTimestamp, lastVisitTimestamp, lastEcommerceOrderTimestamp. So if you’d like to create a cookie to store this data as a backup make sure to update the value each time.

why do you want to create a copy instead of renewing the existing cookie every time a response is sent?

If you do not set the httpOnly flag, it will remain visible in the browser. Regarding ITP and other tracking protections rewriting cookies in a HTTP header will do the job without this flag.

best,
Markus

Thanks Marcus! A bit n00b on this still. Will look further into this!

1 Like