Track UTMs in Samcart Checkout Page
Adding Custom Fields in SamCart
First, let's add custom fields to SamCart as shown below:
The picture only shows utm_source
, but you can add as many parameters as you'd like to track. Check here for a list of the parameters you can track with our solution: What can I track with UTMSimple?
Adding Hidden Fields to Your Checkout Page
Edit your checkout page (Design) and add all the custom fields you've added in Step 1, as shown in the image below.
Insert UTMSimple Code into the Checkout Page
Go to Products > Advanced Settings
and copy-paste the following code into PIXELS > Embed HTML/Scripts in Footer
section. Make sure to update your license key accordingly. This code will hide all the custom fields and prefill them accordingly with the data coming from the client's COOKIES.
<!-- Global site UTM Simple Tracking Start-->
<script>
handl_custom_params=[];var handl_js=document.createElement("script");handl_js.setAttribute("src","https://track.utmsimple.com/utm.js?license=YOURLICENSEKEY"),document.head.appendChild(handl_js),
handl_js.onload=function(){
var data = HandL.getAll()
setTimeout(
function() {
jQuery("[id*='custom']").map((i, v) => {
let key = $(v).next().html()
let c_val = data[key]
if (c_val) {
$(v).val(c_val)
}
})
}, 1000
);
handlj( document ).ready(function() {
handlj("[id*='custom']").map((i, v) => {
handlj(v).parent().parent().parent().hide()
})
})
};
</script>
<!-- Global site UTM Simple Tracking End-->