Advertisement
briank

Centrally-Configure Kartra Countdown Timers

May 19th, 2023 (edited)
968
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.47 KB | None | 0 0
  1. <!--
  2. Centrally-Configured Fixed-Date-And-Time Countdown Timer For Kartra
  3.  
  4. 1. Upload a *plain-text* file containing the event time and expiration redirect URL
  5. (if desired) in this format to the Membership > Files area:
  6.  
  7. eventTime = '2023-05-20T15:00Z'; /* Event date & GMT/UTC time in ISO format */
  8. expirationURL = 'https://example.com'; /* = ''; for no expiration redirect */
  9. resetTimers();
  10.  
  11. 2. Create a tracking link pointing to the configuration file. Reuse this link on all pages
  12. that should share this timer. Just update the target file URL to the new upload URL if/when
  13. updating the configuration.
  14. 3. Add 1+ fixed-date-and-time countdowns to your page with a past date and no redirection.
  15. 4. Add this code to the BODY tracking section of your page, putting the tracking link URL
  16. from step 2 into the script src attribute at the bottom.
  17. -->
  18. <script>
  19. var eventTime, expirationURL, counters = $('[data-countdown] div.countdown').attr('data-date', null);
  20. function resetTimers () {
  21. if (!eventTime) return;
  22. var diffSecs = Math.max(Math.floor((+new Date(eventTime) - new Date()) / 1000), 0);
  23. if (diffSecs <= 0 && expirationURL) location = expirationURL;
  24. counters.each((n, el) => {
  25. var $el = $(el);
  26. $el.stopCountDown();
  27. $el.data('diffSecs', diffSecs);
  28. if (expirationURL) $el.data('callback', () => location = expirationURL);
  29. $el.startCountDown();
  30. });
  31. }
  32. $(() => setTimeout(resetTimers, 0));
  33. </script>
  34. <script src='https://account.krtra.com/tracking_link_here' async defer></script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement