Skip to content

Instantly share code, notes, and snippets.

@chexton
Created November 20, 2013 00:25
Show Gist options
  • Save chexton/7555175 to your computer and use it in GitHub Desktop.
Save chexton/7555175 to your computer and use it in GitHub Desktop.
setup-js-unbounce.js
//1. Add this on the Unbounce page itself:
<script type="text/javascript">
var _veroq = _veroq || [];
_veroq.push(['init', {
api_key: 'YOUR_API_KEY' // UPDATE THIS FROM https://app.getvero.com/account
} ]);
(function() {var ve = document.createElement('script'); ve.type = 'text/javascript'; ve.async = true; ve.src = '//d3qxef4rp70elm.cloudfront.net/m.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ve, s);})();
</script>
//2. Add this on the form confirmation dialog box. I have made comments where you can update things:
<script type="text/javascript">
// ---- Don't edit this section
var _veroq = [];
var getUrlParams = function () {
var params = {},
hash;
var hashes = decodeURI(window.location.href).replace(/\+/g," ").slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
params[hash[0]] = unescape(hash[1]);
}
return params;
};
var urlParam = getUrlParams();
// ---- End of don't edit area
// These are the parameters that the Javascript pulls from the Unbounce form. Whatever they are called in the form, you can grab them here.
var email = urlParam['email'];
var first_name = urlParam['first_name'];
// Here is where you add the user to the Vero database
if (email != undefined) {
_veroq.push(['user', {
email: email,
first_name: first_name
}]);
}
// This is the name of the 'event'. It'll show up in the event list to trigger emails and create segments. You can name it whatever you want :)
_veroq.push(['track', 'Filled out unbounce capture form']);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment