Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Detailed Walk-Through of Marketo Form Values To DayaLayer
<script>
// all the marketo from 2.0 javascript has successfully loaded, so we can continue
MktoForms2.whenReady(function (form) {
// the user has just submitted the form
form.onSubmit(function(){
// marketo provides a form object with a nifty method to get the values from the form
// we'll store those values in a "vals" variable
var vals = form.vals();
// now we can push to the dataLayer
dataLayer.push({
// we get two types of information from this dataLayer push
// the first is the fact that a marketo form was submitted
// in other words: hooray, we got a lead!
'event': 'marketoFormSubmit',
// the second type of information is about the lead itself
// your marketo setup/form will differ; play with the values to get what you need
// just be super careful about personally identifiable info!!
'marketoCompany': vals['Company'],
'marketoLeadSource': vals['LeadSource'],
'marketoOriginalSource': vals['Original_Source_Detail__c'],
'marketoCurrentSource': vals['Source_Detail__c']
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment