Using cookie replication with Munchkin for consistent sessions? | Community
Skip to main content
Casey_Grimes2
New Participant
August 5, 2016
Solved

Using cookie replication with Munchkin for consistent sessions?

  • August 5, 2016
  • 1 reply
  • 2284 views

So, I'm well-aware of what's on this particular Marketo Developers blog entry, but I'm a little stumped on something I'm trying to achieve.

Right now, I have several different domains tied to one Marketo instance. Now, I know when a visitor goes to each website that Marketo is going to write domain-specific cookies for each site—but I'm attempting to route around this by having the server write _mkto_trk values for every website in its own domain-specific cookie once a first visit has been logged on any of those domains. I'd like the session to carry between each domain, so would writing values like

oranges.com: id:123-ABC-456&token_mch-oranges.com-1234567890123-45678

apples.com: id:123-ABC-456&token_mch-apples.com-1234567890123-45678

Alternately, would using a "group" domain (e.g., populating fruitsalad.com across all domains rather than change things) consistently across all domain cookies solve the issue?

Best answer by SanfordWhiteman

If you have an existing (first-party) cookie that doesn't match the default Munchkin pattern, but you want to use it as the cookie for a session, pass the visitorToken arg. For example, if you're on apples.com but you have an associated cookie from oranges.com:

Munchkin.init('AAA-BBB-CCC',{ visitorToken: 'oranges.com: id:123-ABC-456&token_mch-oranges.com-1234567890123-45678' });

Typically, of course you wouldn't have a constant string, unless you were outputting it server-side.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
August 5, 2016

If you have an existing (first-party) cookie that doesn't match the default Munchkin pattern, but you want to use it as the cookie for a session, pass the visitorToken arg. For example, if you're on apples.com but you have an associated cookie from oranges.com:

Munchkin.init('AAA-BBB-CCC',{ visitorToken: 'oranges.com: id:123-ABC-456&token_mch-oranges.com-1234567890123-45678' });

Typically, of course you wouldn't have a constant string, unless you were outputting it server-side.

Casey_Grimes2
New Participant
August 5, 2016

So the trick is to keep the domain consistent even when you're writing to separate domains? If that's the case, that actually makes things much easier.

Also, someone should seriously have documented visitorToken on Munchkin Initialization Parameters. Ugh.

SanfordWhiteman
New Participant
August 5, 2016

Well, that's not the only trick.  You still have to transport the same cookie across domains, which a browser won't do!  I figured you were using some back-end method to do that (such as having people authenticate).