Advertisement
NikolayBezay

Soda stream Form update for optimove.

Dec 16th, 2021
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. <script>
  2. (function() {
  3. var cookieEmailName = '__subscribedus';
  4. var form = document.querySelector('.' + self.identifier + ' [tabindex] form');
  5.  
  6. function writeCookie(key, value, expires) {
  7. var now = new Date();
  8. var time = now.getTime();
  9. time += 3600 * 1000 * 12;
  10. now.setTime(time);
  11. var cookieString = key + '=' + value + '; expires=' + now.toUTCString() + '; path=/';
  12. if (expires) {
  13. cookieString += cookieString + '; expires=' + now.toUTCString() + '; path=/';
  14. } else {
  15. cookieString += cookieString + '; expires=Fri, 31 Dec 9999 23:59:59 GMT"; path=/';
  16. }
  17. window.document.cookie = cookieString;
  18. return value;
  19. };
  20.  
  21. function utf8_to_b64(str) {
  22. return window.btoa(unescape(encodeURIComponent(str)));
  23. }
  24. if (form) {
  25. form.setAttribute('bi-type', 'adoric-form');
  26. form.setAttribute('bi-id', self.campaignTitle);
  27. form.addEventListener('submit', function() {
  28. var emailField = form.querySelector('INPUT[name*="mail"]');
  29. if (emailField) {
  30. writeCookie(cookieEmailName, utf8_to_b64(emailField.value));
  31. }
  32. });
  33. }
  34. })();
  35. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement