briank

Kartra conditional redirect w/ 3rd-party cookies blocked

Aug 5th, 2021 (edited)
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * Force a group of two (or more) Kartra pages to select through conditional tracking links
  3.  * (a work-around for on-page conditional redirects with custom domains and 3rd-party cookie blocking)
  4.  * Replace the link URL with your (first) split conditional tracking link and place in HEADER tracking.
  5.  * Author: Brian Katzung
  6.  */
  7. if (window.sessionStorage) {
  8. var link = "https://account.krtra.com/t/something", key = 'did_' + link.replace(/.*\//, ''), now = +new Date, red = document.querySelector('meta[data-redirect]');
  9. if (red) red.remove();
  10. if (now - (sessionStorage[key] || 0) > 5000) { sessionStorage[key] = now; location = link; }
  11. else delete sessionStorage[key];
  12. }
Add Comment
Please, Sign In to add comment