Files
medicalalert-web-reloaded/wp/wp-content/themes/thbusiness/inc/cookie-data.php
Tony Volpe 4eb982d7a8 Merged in feature/from-pantheon (pull request #16)
code from pantheon

* code from pantheon
2024-01-10 17:03:02 +00:00

61 lines
1.5 KiB
PHP

<?php
function CookieData() { ?>
<script type="text/javascript">
jQuery(document).ready(function(){
function setCookie(name, value, days){
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
var expires = "; expires=" + date.toGMTString();
document.cookie = name + "=" + value + expires;
}
function getParam(p){
var match = RegExp('[?&]' + p + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
var gclid = getParam('gclid');
var CustomField1 = getParam('CustomField1');
var CustomField2 = getParam('CustomField2');
var CustomField3 = getParam('CustomField3');
var CustomField4 = getParam('CustomField4');
var cid = getParam('cid');
if(gclid){
var gclsrc = getParam('gclsrc');
if(!gclsrc || gclsrc.indexOf('aw') !== -1){
setCookie('gclid', gclid, 90);
}
}
function readCookie(name) {
var match = document.cookie.match(new RegExp(name + '=([^;]+)'));
if (match) {
return match[1];
}
return undefined;
}
jQuery('input[name="gclid_data"]').val(readCookie('gclid'));
jQuery('input[name="CustomField1"]').val(readCookie('CustomField1'));
jQuery('input[name="CustomField2"]').val(readCookie('CustomField2'));
jQuery('input[name="CustomField3"]').val(readCookie('CustomField3'));
jQuery('input[name="CustomField4"]').val(readCookie('CustomField4'));
jQuery('input[name="cid"]').val(readCookie('cid'));
});
</script>
<?php
}