Note: you need access to your tracking code to use that feature.

If you want to collect UTM parameters for any campaign

Script setup

Paste the following script between the end of your WisePops tracking code and the </script> tag.

 /**
 *  CUSTOM SCRIPT
 */
jQuery(document).ready(function($) {
(function () {
var wisepopId = '';
var getParamNames = ['utm_source', 'utm_campaign', 'utm_medium'];

function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
$('body').one('mouseenter', "[id^=\'wisepop-"+ wisepopId +"\']", function() {
    getParamNames.forEach(function(getParamName) {
        $('[data-name=\'' + getParamName.split('_').map(capitalizeFirstLetter).join(' ') + '\']').val(getUrlVars()[getParamName])
    }, this);
});
})();
});


The final result should look like that:

 <script type="text/javascript">
    /**
     * WISEPOPS TRACKING CODE
     */
  (function(W,i,s,e,P,o,p){W['WisePopsObject']=P;W[P]=W[P]||function(){
  (W[P].q=W[P].q||[]).push(arguments)},W[P].l=1*new Date();o=i.createElement(s),
  p=i.getElementsByTagName(s)[0];o.async=1;o.src=e;p.parentNode.insertBefore(o,p)
  })(window,document,'script','//loader.wisepops.com/get-loader.js?v=1&user_id=XXXXX','wisepops');
/**
 *  CUSTOM SCRIPT
 */
jQuery(document).ready(function($) {
(function () {
var wisepopId = '';
var getParamNames = ['utm_source', 'utm_campaign', 'utm_medium'];
function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}
function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
$('body').one('mouseenter', "[id^=\'wisepop-"+ wisepopId +"\']", function() {
    getParamNames.forEach(function(getParamName) {
        $('[data-name=\'' + getParamName.split('_').map(capitalizeFirstLetter).join(' ') + '\']').val(getUrlVars()[getParamName])
    }, this);
});
})();
});
</script>

Create the fields to collect the UTMs

Open your campaign in the editor.
Click the email field.

In the left menu, click "Add new Field"


Select "Hidden field" in the upper right menu.

Name it Utm Source (using a different name will break the code).

Repeat the operation for Utm Campaign and Utm Medium.

Save your popup.

Done!

If you want to collect UTM parameters for a specific campaign


Use the following script instead.
After "wisepopId", enter your campaign ID (it can be found in the URL when you open your campaign in the editor).

/**
 *  CUSTOM SCRIPT
 */
jQuery(document).ready(function($) {
(function () {
var wisepopId = xxxx;
var getParamNames = ['utm_source', 'utm_campaign', 'utm_medium'];

function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
$('body').one('mouseenter', "[id^=\'wisepop-"+ wisepopId +"\']", function() {
    getParamNames.forEach(function(getParamName) {
        $('[data-name=\'' + getParamName.split('_').map(capitalizeFirstLetter).join(' ') + '\']').val(getUrlVars()[getParamName])
    }, this);
});
})(); });
Did this answer your question?