Add Location Data from RTP API to Marketo Form Fill Out

September 17, 2014 | by

You’ll need active RTP and MLM subscriptions to implement the use case described in this blog post.

Using the RTP JavaScript APIs and Marketo Forms 2.0, you can pull the inferred location data from RTP and push it into Marketo via a form fill out. This will allow you to see the user’s inferred location (based on IP address) during the most recent form activity.

To get started, you will need to create three custom string fields in Marketo. You can do this either via your CRM if it has a native integration with Marketo, or from the Field Management menu in Marketo’s admin section. I recommend naming these fields ‘Most Recent Country’, ‘Most Recent State’, and ‘Most Recent City.’ We’ll continue this blog using this naming convention. The API names for these fields will be ‘mostRecentCountry’, ‘mostRecentState’, and ‘mostRecentCity’.

To retrieve the location data, we’ll be using the RTP method to get the visitor’s location data, and then pass it into the form using the addHiddenFields and vals methods from the Marketo Forms 2.0.

On your page, add your RTP JS tag and a Marketo form. Then, include the script below. You will need to change the names of the target form fields in the example code if you are using a different naming convention than the one described above.