Im working on this bit, its fully functional, what it does is to write a cookie and pass it to a hidden field:
// part 1 - get and parse cookie string
$(window).load(function(){
var cookieString = document.cookie;
var parsedCookie = cookieString.split(";");
var hutk = '';
for(var i=0; i<parsedCookie.length; i++){
var eachCookie = parsedCookie[i].split('=');
if(eachCookie[0] == ' hubspotutk'){
hutk += eachCookie[1];
}
}
// part 2 - populate the cookie string into hidden field name contextJSON
var context = new Object();
context.hutk = hutk;
context.pageUrl = window.location.href;
context.pageName = document.title;
context.redirectUrl = 'https://info.cos.net.au/thank-you';
document.getElementById('contextJSON').value = JSON.stringify(context);
});
how can i get the customer's ipAddress by javasccript or jquery and add it on top of the existing string in part 2? many thanks