Skip to content

Instantly share code, notes, and snippets.

@balindenberg
Last active May 3, 2022 20:16
Show Gist options
  • Select an option

  • Save balindenberg/454f91149006d2f2047eee29a5428a0e to your computer and use it in GitHub Desktop.

Select an option

Save balindenberg/454f91149006d2f2047eee29a5428a0e to your computer and use it in GitHub Desktop.
Dynamic Personalization Snippet
<script defer>
setTimeout(()=> {
// Set your data in these fields from the DOM or JS layer, e.g. set name to document.getElementById('viewer_name').innerHTML.trim()
var params = {
name: "",
email: "",
phone: "",
custom_id: "",
}
var queryString = Object.keys(params).map(function(key) {
return params[key] ? key + '=' + params[key] : ''
})
queryString = queryString.filter(Boolean).join("&")
if (queryString.length) {
frames = document.getElementsByTagName("iframe");
for (i = 0; i < frames.length; ++i) {
if (frames[i].src.includes("mindstamp") || frames[i].src.includes("myinteractive")) {
var url = frames[i].src + (frames[i].src.includes("?") ? "&"+queryString : "?"+queryString)
frames[i].src = url
}
}
}
})
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment