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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<script> //modify the form and grab the user MktoForms2.whenReady( function(form) { //add the hidden fields to the form form.addHiddenFields({ "mostRecentCountry":"", "mostRecentState":"", "mostRecentCity":""}); //Grab the visitor data, a JS object with it is passed in the callback function of the third argument rtp('get','visitor',function(visitor){ //add the desired info from the visitor object to the form fields form.vals({ "mostRecentCountry":visitor.results.location.country, "mostRecentCity":visitor.results.location.city, "mostRecentState":visitor.results.location.state}); } ); }); </script> |