Referring someone new via a Marketo form (and attributing that referral to the person who submitted the form) | Community
Skip to main content
New Participant
April 14, 2022
Solved

Referring someone new via a Marketo form (and attributing that referral to the person who submitted the form)

  • April 14, 2022
  • 1 reply
  • 6402 views

Hi all,

 

As the title suggests, I would like a functionality that will allow users to submit a form referring a new person. When the form is submitted, a new record will be created within Marketo. Ideally I would like to do this without the use of JavaScript hacks (ideally I would prefer a webhook). I've searched, but I can't find any topics specifically covering this (I don't need to do anything more complicated than simply submitting a form that creates a new record (referee) and updates an existing one (referrer)). Is this possible at all?

 

Thanks!

Best answer by Darshil_Shah1

@marianoadunseco wrote:

I see @darshil_shah1 . So in the example, you provided, the "FA's Email" populates to a hidden form field (on the same form) when the form is submitted to the visible form field value that corresponds to it (in the hidden field)? Just so I'm understanding this correctly (I believe I am but would like to verify). 

 

In Sandy's script the "FA's Email" field's value is not appended to any hidden field during the referrer's form submission (i.e., during the form submission 1), but this can be easily done with the formObject.setValues() function (we would need the API name of the field(s) to which the referee's email and/or other details need to be added during referrer form submission).

 

 

In which case, If I needed to add a First Name, Last Name, Country and Company for the referee, I would need to do this:

 

'Email': originalValues['Email_Address_2__c'],

'FirstName': OriginalValues['Email_Address_2__c'],

'ComapnyName': OriginalValues['Email_Address_2__c'],

 

You need to replace the 'Email_Address_2__c' with the actual fields' API names being used in the form - you can find the API names of the fields from the field management, read about it here.

 


 

Finally, I'm a little in the dark about this other aspect of the script... What do these numbers need to be populated with?:

 

MktoForms2.loadForm("//app-sj01.marketo.com", "410-XOR-673", 441);

 


Well, these are not just random characters - these are the baseUrl, munchkinId, and formId, respectively you can look for these values in the Embed Form code - go to Marketo > Navigate to and select the Marketo form you're gonna use for this project > Select Form Actions in the right Pane > Click on the Embed Code - A dialog box will appear with the script to embed the form - this script will have MktoForms2.loadForm("<baseUrl>", "<MunchkinId>", <formId>) - you need to plug values you see here into the actual script. 

 

 

And apologies to ask another set of questions - but what other aspects of the script need to be customised with values unique to your own form and LP?

 

Is that correct? And I'd assume the scripts would sit at layout template level...


This is a starter script with the recipe for the multiple form submissions, clearing cookies after first submission, assigning apt referrer and referee data during each of the form submissions - you need to update the API names of the fields you're using in the form, instance base URL, munchkin-id, form-id, and the form-js script address.

 

This can be added at the LP/webpage level unless all the LPs you're gonna create from the template need to reference this script.

1 reply

Darshil_Shah1
Community Manager
April 14, 2022

Well, it's pretty straight fwd if you do via JS - you can build a form that let's the referrer add data about themselves and also the referee - you can clear the referee details during the first form POST in the onSubmit() function (thereby submitting the referrer data only in form post 1), and in the onSuccess() function set the form field values for the referee and make an another POST (i.e., form submission for submitting the referee data). You can use hidden field(s) to add data about the referee while submitting the form for referrer - for attribution.

 

Just to clarify, both the form submissions are regular/usual Marketo form submissions - i.e., a new lead will be created if not already present in the database, else an existing lead with the matching email address will be updated.

 

Before submitting the form again for the referee - JS can take care of clearing out the previously created cookie as well, as per this Marketo dev page.

 

You can refer Sandy's sample script to pull this off here (it's pretty sleek and straight fwd).

New Participant
April 18, 2022

I see @darshil_shah1 . So in the example, you provided, the "FA's Email" populates to a hidden form field (on the same form) when the form is submitted to the visible form field value that corresponds to it (in the hidden field)? Just so I'm understanding this correctly (I believe I am but would like to verify). 

 

In which case, If I needed to add a First Name, Last Name, Country and Company for the referee, I would need to do this:

 

'Email': originalValues['Email_Address_2__c'],

'FirstName': OriginalValues['Email_Address_2__c'],

'ComapnyName': OriginalValues['Email_Address_2__c'],

 

Finally, I'm a little in the dark about this other aspect of the script... What do these numbers need to be populated with?:

 

MktoForms2.loadForm("//app-sj01.marketo.com", "410-XOR-673", 441);

 

And apologies to ask another set of questions - but what other aspects of the script need to be customised with values unique to your own form and LP?

 

Is that correct? And I'd assume the scripts would sit at layout template level...

Darshil_Shah1
Darshil_Shah1Accepted solution
Community Manager
April 18, 2022

@marianoadunseco wrote:

I see @darshil_shah1 . So in the example, you provided, the "FA's Email" populates to a hidden form field (on the same form) when the form is submitted to the visible form field value that corresponds to it (in the hidden field)? Just so I'm understanding this correctly (I believe I am but would like to verify). 

 

In Sandy's script the "FA's Email" field's value is not appended to any hidden field during the referrer's form submission (i.e., during the form submission 1), but this can be easily done with the formObject.setValues() function (we would need the API name of the field(s) to which the referee's email and/or other details need to be added during referrer form submission).

 

 

In which case, If I needed to add a First Name, Last Name, Country and Company for the referee, I would need to do this:

 

'Email': originalValues['Email_Address_2__c'],

'FirstName': OriginalValues['Email_Address_2__c'],

'ComapnyName': OriginalValues['Email_Address_2__c'],

 

You need to replace the 'Email_Address_2__c' with the actual fields' API names being used in the form - you can find the API names of the fields from the field management, read about it here.

 


 

Finally, I'm a little in the dark about this other aspect of the script... What do these numbers need to be populated with?:

 

MktoForms2.loadForm("//app-sj01.marketo.com", "410-XOR-673", 441);

 


Well, these are not just random characters - these are the baseUrl, munchkinId, and formId, respectively you can look for these values in the Embed Form code - go to Marketo > Navigate to and select the Marketo form you're gonna use for this project > Select Form Actions in the right Pane > Click on the Embed Code - A dialog box will appear with the script to embed the form - this script will have MktoForms2.loadForm("<baseUrl>", "<MunchkinId>", <formId>) - you need to plug values you see here into the actual script. 

 

 

And apologies to ask another set of questions - but what other aspects of the script need to be customised with values unique to your own form and LP?

 

Is that correct? And I'd assume the scripts would sit at layout template level...


This is a starter script with the recipe for the multiple form submissions, clearing cookies after first submission, assigning apt referrer and referee data during each of the form submissions - you need to update the API names of the fields you're using in the form, instance base URL, munchkin-id, form-id, and the form-js script address.

 

This can be added at the LP/webpage level unless all the LPs you're gonna create from the template need to reference this script.