Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hasAffiliateParam = window.location.href.indexOf("ref") > -1;
- var affiliateId = null;
- if (hasAffiliateParam) {
- var queryString = window.location.href.split("?")[1];
- queryString = queryString.split("#")[0];
- var arr = queryString.split("&");
- for (var i = 0; i < arr.length; i++) {
- var keyAndValue = arr[i].split("=")
- if (keyAndValue[0] === "ref") {
- affiliateId = keyAndValue[1];
- break;
- }
- }
- }
- function setCookie(cname, cvalue, exdays) {
- var d = new Date();
- d.setTime(d.getTime() + (exdays*24*60*60*1000));
- var expires = "expires="+ d.toUTCString();
- document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
- }
- if (affiliateId) {
- setCookie("affwp_ref", affiliateId, 365)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement