SOLVED

Capturing eVars in Marketo Forms

Go to solution
Helen_Abramova1
Level 5

Capturing eVars in Marketo Forms

Hello,

Did anyone have experience of using eVars instead of UTM parameters? How do you set up your hidden fields? Can't find any docs or advice on that so far.

Thanks!

Helen

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing eVars in Marketo Forms

If it's just parsing the current query string (from the page the form is on) then it doesn't matter that they're "eVars" per se. They're just a query parameter that needs to be split up before adding to the form.

Create a String field allEVars to store the whole thing for posterity. Add that field to the form in Form Editor, as Hidden + Auto-Fill from the query param.

Then

MktoForms2.whenReady(function(form){

var currentValues = form.getValues(),

eVarHeaders = "evar_medium:evar_source:evar_campaign:evar_other:evar_etc".split(":"),

eVarSingleFields = currentValues.allEVars

.split(":")

.reduce(function(acc,next,idx){

acc[eVarHeaders[idx]] = next;

return acc;

},{});

form.addHiddenFields(eVarSingleFields);

});

This will populate individual hidden fields from the fields in the eVarHeaders semicolon-delimited string, in that order. (You'll create all those fields in Marketo as well, but they don't need to formally appear on the form in Form Editor).

View solution in original post

4 REPLIES 4
SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing eVars in Marketo Forms

Are you referring to reading previously set eVars from the Adobe session? This is problematic for the clear reason that they aren't meant to be re-read from the server (as they are considered important on the server side).

Helen_Abramova1
Level 5

Re: Capturing eVars in Marketo Forms

To be honest, I am still figuring it out. We have eVar-tagged links, a user clicks through and lands on a landing page, fills out a form - I hope to be able to capture them by the hidden fields. The links look as follows:

www.mydomain.com/?aaa:bbb:ccc:ddd

aaa, bbb, etc. are the values for the eVar parameters [they are supposed to work very similar to UTM parameters], the same order all the time, and always separated by semi-column. I think we should be able to capture those.

SanfordWhiteman
Level 10 - Community Moderator

Re: Capturing eVars in Marketo Forms

If it's just parsing the current query string (from the page the form is on) then it doesn't matter that they're "eVars" per se. They're just a query parameter that needs to be split up before adding to the form.

Create a String field allEVars to store the whole thing for posterity. Add that field to the form in Form Editor, as Hidden + Auto-Fill from the query param.

Then

MktoForms2.whenReady(function(form){

var currentValues = form.getValues(),

eVarHeaders = "evar_medium:evar_source:evar_campaign:evar_other:evar_etc".split(":"),

eVarSingleFields = currentValues.allEVars

.split(":")

.reduce(function(acc,next,idx){

acc[eVarHeaders[idx]] = next;

return acc;

},{});

form.addHiddenFields(eVarSingleFields);

});

This will populate individual hidden fields from the fields in the eVarHeaders semicolon-delimited string, in that order. (You'll create all those fields in Marketo as well, but they don't need to formally appear on the form in Form Editor).

Helen_Abramova1
Level 5

Re: Capturing eVars in Marketo Forms

This is great, thank you so much!!!

Helen