NikolayBezay

Adoric custom GEO IP trigger event.

Dec 21st, 2020 (edited)
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.75 KB | None | 0 0
  1. <script>
  2. (function() {
  3.     function sendEvent() {
  4.         checkCounter--;
  5.         if (dataLayer && ga && adoric) {
  6.            window.dataLayer.forEach(function(item) {
  7.                if (typeof(item) === 'object' && item.a) {
  8.                     window.adoricGeoIpState = item.a.geoData.state_prov;
  9.                     window.ga('t0.send', 'event', {
  10.                         eventCategory: 'Adoric - Geo IP trigger',
  11.                         eventAction: 'Enter',
  12.                         eventLabel: item.a.geoData.state_prov
  13.                     });
  14.                 }
  15.             });
  16.         } else if(checkCounter > 0) {
  17.             setTimeout(sendEvent, 1000);
  18.         }
  19.     }
  20.     var checkCounter = 5;
  21.     setTimeout(sendEvent, 1000);
  22. })();
  23. </script>
  24.  
Advertisement
Add Comment
Please, Sign In to add comment