Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Mikael Malmgren
Added: Aug 2, 2018 1:12 PM
Views: 7
Tags: no tags
  1. <script>
  2.  
  3.  var cookieName = "CTA"; // Name of your cookie
  4.  var cookieValue = '{{Click Text}}|{{Page Path}}'; // Value of your cookie
  5.  expirationTime = expirationTime * 1000; // Converts expirationtime to milliseconds
  6.  var date = new Date();
  7.  var dateTimeNow = date.getTime();
  8.  
  9.  date.setTime(dateTimeNow + expirationTime); // Sets expiration time (Time now + one month)
  10.  var expirationTime = date.toUTCString(); // Converts milliseconds to UTC time string
  11.  document.cookie = cookieName+"="+cookieValue+"; expires="+expirationTime+"; path=/; domain=." + location.hostname.replace(/^www\./i, ""); // Sets cookie for all subdomains
  12.  
  13. </script>