How to Record Conversions using GTM and Google Analytics

1.1 Open Variables in GTM and click New

310.width-800

1.2 Define variable type

311.width-800

1.3 Configure variable to store ref value

312.width-800

1.4 Create another variable to keep tracking the final submission step of form

313.width-800

2.1 Open Triggers and add a NEW trigger

314.width-800

2.2 Choose trigger type

315.width-800

2.3 Configure trigger as shown

316.width-800

2.4 Trigger final screen to look like below

317.width-800

3.1 Open tags and add one

318.width-800

3.2 Choose tag type

319.width-800

3.3 Configure tag as shown

320.width-800

3.4 Click in trigger area to open mapping of trigger to fire

321.width-800

3.5 Choose the trigger which we created earlier

322.width-800

3.6 Tag creation final screen will look like

323.width-800

4.1 Navigate to Settings > Custom Scripts inside your EnrolHQ and paste the following into the Javascript box and save

var step3_count = 5;
function update_utm_value() {
if ($('#enrolhq_form').length && step3_count < 5) {
var step = $("#step-3").length;
if (step > 0) {
setCookie('utm_final_step', '1');
step3_count = 5;
} else {
setCookie('utm_final_step', '0');
step3_count++;
setTimeout(function () {
update_utm_value();
}, 1000);
}
}
}

$(window).on('load', function () {
setTimeout(function () {
setCookie('utm_final_step', '0');
update_utm_value();
}, 1500);

var formname = getParameterByName('ref');
var set_utm = function setutm(utm_param, utm_val) {
if (utm_val != "") {
setCookie('utm_' + utm_param, utm_val);
}
};
setTimeout(function () {
set_utm('ref', formname);
}, 1500);

$(document).on("click", '#enrolhq_form .btn', function () {
step3_count = 1;
update_utm_value();
});

});

function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
let expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}

function getCookie(cname) {
let name = cname + "=";
let ca = document.cookie.split(';');
for (let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}