_mkto_trk hidden field population issue

Josh_Soffe2
Level 2

Hi All,

I'm having an issue on our corporate website of capturing the _mkto_trk value within a hidden field, from the cookie dropped by the Munchkin.js script. It seems to be sporadically appearing and this is obviously an issue that impacts Anonymous > Known attribution. Can anyone help?

Image below of location of form :

Website image.PNG

11 REPLIES 11
Josh_Soffe2
Level 2

Thanks for the help - I found that as the form was opening in a lightbox that the form HTML was being loaded from an external source so the cookie value wasn't being burned in on page load. Issue is resolved by attached the Munchkin script to the external location so on load (render) the value is attached.

pastedImage_1.png

SanfordWhiteman
Level 10 - Community Moderator

As long as the external location shares a parent domain with the main location (pages.example.com/www.example.com) then the Munchkin cookie will already be in the browser's cookie store.  You don't need to load (nor init()) Munchkin to access the cookie. In fact I don't advise loading Munchkin in an IFRAME like this (which seems to be what you're talking about) because then you see a needless Visit Web Page activity for the LP every time somebody loads the form.

Josh_Soffe2
Level 2

Update: After some further testing it appears that the cookie value is only 'burned in' once and this on the initial munchkin load. The forms are non-marketo embedded forms, loaded in lightboxes. The munchkin script was running (once) on page load and not attaching the cookie ID value to the hidden _mkt_trk field. Thus we have two options available:

Option 1: Use responsive Marketo forms 2.0 adopting the same styling as the current page

Option 2: Use simple script that on form load, pulls the Munchkin ID from the cookie parameter and puts into the _mkt_trk field e.g.

var cookie_val = $.cookie("name");
$
('input[name=cookie]').val(cookie_val);

SanfordWhiteman
Level 10 - Community Moderator

Yes, if your server is not going to reliably render the _mkto_trk cookie into the server response, then you'll need to extract it on the client and put it in the form.

The cookie value is never automatically extracted and added to a hidden field unless the form is a Marketo form.  Your form has to be built to use the cookie: Munchkin just creates the cookie, it doesn't place it into your custom HTML.

Josh_Hill13
Level 10 - Champion Alumni

What exactly do you want to do?


Marketo itself handles Anon > Known so you shouldn't have to manually deal with that.

Josh_Soffe2
Level 2

Hi Josh,

I’d like to pull in the Marketo Cookie ID as per the ‘Server Side Post’ setup the mktotrk field on my form in order to aatribute past web behaviour to the known lead that is generated in the system.

Josh Soffe

Marketing Technology Manager

BAE Systems Applied Intelligence

Grant_Booth
Level 10

Hey Josh,
Could you describe how the form is built? Is it possible that the form is loading on the page after the munchkin script has already executed, at least some of the time (i.e. a racing issue)?

Josh_Soffe2
Level 2

Hi grant,

Thanks for reaching out.

The form loads in a light box on clicking the contact button. This even would indeed happen after the script has loaded. The form is a server side post you can take a look at the form using the screenshot I supplied below?

Sent via Email+ secured and managed by MobileIron

SanfordWhiteman
Level 10 - Community Moderator

First, server-side post is not really recommended.  The "form proxy" pattern (client --> your server --> Marketo's server) is rate-limited and complex, and typically unnecessary.

The mkto_trk cookie is generated in the browser, but the Munchkin library needs to have bootstrapped, downloaded, and initialized first, and if you are using excessive and/or broken asynchronous loading, this may not complete before the form is populated.

But a screenshot isn't really possible to troubleshoot.  We need the actual URL.  Is this https://www.baesystems.com? I don't see Munchkin even attempting to load there.

Josh_Soffe2
Level 2

Hi Sanford,

The form appears in a pop-up after clicking the ‘Contact Sales’ button about halfway down this site http://www.baesystems.com/en/cybersecurity/home (which is tracked by asynchronous JQuery Munchkin)

Josh Soffe

Marketing Technology Manager

BAE Systems Applied Intelligence

SanfordWhiteman
Level 10 - Community Moderator

Well, the _mkto_trk is present in the browser and is sent in the HTTP headers when the form's HTML fragment is requested, but it doesn't end up in the form's hidden field ​_mkt_trk. 

​I assume you expect the ​_mkt_trk ​to be rendered on your server ("burned" into the form HTML, if you will) based on the cookies the server receives in the request.  If so, the bug is in your server code, because it does have the cookie sent to it, but it isn't putting it in the HTML response.