How to add UTM forwarded javascript to Marketo embedded form script? | Community
Skip to main content
Jina_Watson
New Participant
September 4, 2020
Question

How to add UTM forwarded javascript to Marketo embedded form script?

  • September 4, 2020
  • 0 replies
  • 1249 views

I'm not someone that uses Javascript. For the instructions of inserting this code into the Marketo embedded form code, how does it drop in exactly?

 

Like this:

 

 

<script src="//app-lon07.marketo.com/js/forms2/js/forms2.min.js"></script> <script>(function(opts){ var current = { state : document.location.href, query : document.location.search.substring(1), time : new Date().getTime() }, storage = { area : window.localStorage, key : 'last_utm_query' }, restored, updated = {}; if (/(^|&)utm_/.test(current.query)) { storage.area[storage.key] = JSON.stringify({ time:current.time, query:current.query }); } else if (restored = JSON.parse(storage.area[storage.key] || '""')) { if ( window.MktoForms2 && ( current.time - restored.time <= opts.expireDays * 864E5 ) ) { updated.state = document.createElement('a'); updated.state.href = current.state; updated.state.search += (updated.state.search ? '&' : '') + restored.query + '&restored=' + restored.time; history.replaceState('', {}, updated.state); } } })({ expireDays : 30 });</script> <form id="mktoForm_1043"></form> <script>MktoForms2.loadForm("//app-lon07.marketo.com", "041-BQO-927", 1043);</script>

 

 

 

Or like this:

 

 

<script src="//app-lon07.marketo.com/js/forms2/js/forms2.min.js">(function(opts){ var current = { state : document.location.href, query : document.location.search.substring(1), time : new Date().getTime() }, storage = { area : window.localStorage, key : 'last_utm_query' }, restored, updated = {}; if (/(^|&)utm_/.test(current.query)) { storage.area[storage.key] = JSON.stringify({ time:current.time, query:current.query }); } else if (restored = JSON.parse(storage.area[storage.key] || '""')) { if ( window.MktoForms2 && ( current.time - restored.time <= opts.expireDays * 864E5 ) ) { updated.state = document.createElement('a'); updated.state.href = current.state; updated.state.search += (updated.state.search ? '&' : '') + restored.query + '&restored=' + restored.time; history.replaceState('', {}, updated.state); } } })({ expireDays : 30 });</script> <form id="mktoForm_1043"></form> <script>(function(opts){ var current = { state : document.location.href, query : document.location.search.substring(1), time : new Date().getTime() }, storage = { area : window.localStorage, key : 'last_utm_query' }, restored, updated = {}; if (/(^|&)utm_/.test(current.query)) { storage.area[storage.key] = JSON.stringify({ time:current.time, query:current.query }); } else if (restored = JSON.parse(storage.area[storage.key] || '""')) { if ( window.MktoForms2 && ( current.time - restored.time <= opts.expireDays * 864E5 ) ) { updated.state = document.createElement('a'); updated.state.href = current.state; updated.state.search += (updated.state.search ? '&' : '') + restored.query + '&restored=' + restored.time; history.replaceState('', {}, updated.state); } } })({ expireDays : 30 }); MktoForms2.loadForm("//app-lon07.marketo.com", "041-BQO-927", 1043);</script>

 

 

Or some other way I'm not interpreting?

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.