Created
April 30, 2018 21:53
-
-
Save patrickhaley/72a98a1978e5943a440e28ca4eec5158 to your computer and use it in GitHub Desktop.
PlaceThe following Javascript code must be placed at the bottom of each page in your website. It should not be placed inside any HTML tags and should be the last code before the </body> tag.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Pass URL Parameters to NetSuite --> | |
<!-- https://system.na3.netsuite.com/app/help/helpcenter.nl?fid=section_N979468.html --> | |
<script type="text/javascript"> | |
<!-- | |
function getNS_url_param( name ){ | |
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); | |
var regexS = "[\\?&]"+name+"=([^&#]*)"; | |
var regex = new RegExp( regexS ); | |
var results = regex.exec( window.location.href ); | |
if( results == null ) | |
return ""; | |
else | |
return results[1]; | |
} | |
function trackNSParams() { | |
var name = 'campaignevent'; | |
var value = getNS_url_param(name); | |
if (value != null && value.length > 0) | |
document.cookie = name+"="+value+"; max-age=2592000; path=/"; | |
} | |
function appendNSParams(url) { | |
var nameEQ = "campaignevent="; | |
var url = document.getElementById('ns_form').action; | |
var ca = document.cookie.split(';'); | |
for (var i = 0; i < ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) == ' ') c = c.substring(1, c.length); | |
if (c.indexOf(nameEQ) == 0) | |
url = url + '&' + nameEQ + c.substring(nameEQ.length, c.length); | |
} | |
document.getElementById('ns_form').action = url; | |
} | |
// --> | |
trackNSParams(); | |
</script> | |
<!-- End Pass URL Parameters to NetSuite --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment