Skip to content

Instantly share code, notes, and snippets.

@mabumusa1
Created November 26, 2017 11:26
Show Gist options
  • Save mabumusa1/eb39fe696a16d78d944607bc2920ab08 to your computer and use it in GitHub Desktop.
Save mabumusa1/eb39fe696a16d78d944607bc2920ab08 to your computer and use it in GitHub Desktop.
Implementing UTM tracking with Wufoo forms
<html>
<body>
<script>
function getParameterByName(name) {
url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function getDefaultValuesString(){
values = '';
values += 'Field232=' + getParameterByName('utm_content');
values += '&Field233=' + getParameterByName('utm_source');
values += '&Field234=' + getParameterByName('utm_medium');
values += '&Field235=' + getParameterByName('utm_campaign');
values += '&Field237=' + getParameterByName('utm_term');
return values.toString();
}
</script>
<div id="wufoo-w1tgylst1jh6qa6">
Fill out my <a href="https://usersproof.wufoo.eu/forms/w1tgylst1jh6qa6">online form</a>.
</div>
<script type="text/javascript">var w1tgylst1jh6qa6;(function(d, t) {
var s = d.createElement(t), options = {
'userName':'',
'formHash':'',
'autoResize':true,
'height':'1955',
'async':true,
'host':'wufoo.eu',
'header':'show',
'defaultValues': getDefaultValuesString(),
'ssl':true};
s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'www.wufoo.eu/scripts/embed/form.js';
s.onload = s.onreadystatechange = function() {
var rs = this.readyState; if (rs) if (rs != 'complete') if (rs != 'loaded') return;
try { w1tgylst1jh6qa6 = new WufooForm();w1tgylst1jh6qa6.initialize(options);w1tgylst1jh6qa6.display(); } catch (e) {}};
var scr = d.getElementsByTagName(t)[0], par = scr.parentNode; par.insertBefore(s, scr);
})(document, 'script');</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment