SOLVED

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

Go to solution
MarianoAdunseCO
Level 2

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!

Tags (1)
2 ACCEPTED SOLUTIONS
Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

@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.

View solution in original post

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

You would want the  '_mkt_trk': '' in the on Success method, I was rather talking about below line from the code snippet's snapshot you posted in your earlier comment. 

 

Darshil_Shah1_1-1650875017664.png

 

I made one test submission - I didn't see any errors and also did see the 2 success (200 OK) calls to the save endpoint. Do you see the records at your end?

 

View solution in original post

25 REPLIES 25
m_halmeenmaki
Level 1

Hi @SanfordWhiteman thanks a lot for the script.

 

Referral email data gets appended correctly, but I'm running into an issue with consistently getting 3 duplicate referrals being created on Marketo (4 in total). Any idea what can cause this?

SanfordWhiteman
Level 10 - Community Moderator

No way to tell without linking to your page.

m_halmeenmaki
Level 1

I had your Codepen embedded on the form itself as a script in rich text field. After moving it to the landing page, everything looks to be working correctly.

 

Is it possible to append a data point from the referrer to the newly created, referred lead? Say, I want to move a CSM owner field value that the referrer has, can I add this to the script if we know that value at form fill?

SanfordWhiteman
Level 10 - Community Moderator

I had your Codepen embedded on the form itself as a script in rich text field. After moving it to the landing page, everything looks to be working correctly.

Yes, it’s not safe to simply drop scripts into Rich Text areas, as they’ll run multiple times. There’s a blog post about this specific case.

 


Is it possible to append a data point from the referrer to the newly created, referred lead? Say, I want to move a CSM owner field value that the referrer has, can I add this to the script if we know that value at form fill?

You mean if you know the value via Pre-Fill?

 

Sure, any hidden field that’s not specifically removed is already added to the referral lead.

 

So if you had CSM Name in a hidden field it would be taken from the referrer and posted to the referral (as well as being posted back to the referrer with the same value).

Darshil_Shah1
Level 10 - Community Advisor + Adobe Champion

@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.