Extracting and tracking data from other cookies

My goal is to extract an identifier from a Marketo cookie and include it in Snowplow-tracked events on our website. I know very little about Javascript :expressionless:
Info on the Marketo cookie is here.

I’ve found two things in the snowplow docs:

  1. Extracting GA cookie id
  2. setUserIdFromCookie

What is the difference between these two approaches?
Naive JS question: do I have to make sure the Marketo JS script is above the Snowplow JS script to ensure that the Marketo cookie is defined before I try to extract the identifier?

Hi @dweitzenfeld,

Which way to go depends on the complexity of the cookie’s value.

Generally, a cookie is saved in a name-value pair like cookie_name=value. Therefore if the cookie contains just the user id, for example userId=abc123 then you could retrieve that value and set it (implicitly) with a function call like:

snowplow('setUserIdFromCookie', 'userId');

However, quite often the cookie’s value is more complected as is the case with Google Analytics. First, you would have to extract the ID and then manually (explicitly) set it with setUserId.

Judging by the look of the Marketo cookie you would have to come up with a function extracting the ID first as the cookie appears to be made up of a couple of values (where ID is just one of them) and follows the pattern id:561-HYG-937&token:_mch-marketo.com-1374552656411-90718.


1 Like

Thanks Ihor!