Advertisement
NikolayBezay

Quick LIVE env. custom GTM tag to show campaign by cart limit and click over payment button.

Feb 24th, 2023
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <script>
  2. (function() {
  3. var MIN_TOTAL_CART_SUM_LIMIT = 400;
  4. var MAX_TOTAL_CART_SUM_LIMIT = 498;
  5. var SHOW_CAMPAIGN_EVENT_NAME = 'showDeliveryPlanCampaign';
  6.  
  7. function checkCheckoutState() {
  8. return window.location.href.indexOf('section=checkout') !== -1;
  9. }
  10.  
  11. function checkPaymentCampaign() {
  12. var cartWrapper = document.querySelector('[class*="cartWrapper"]');
  13. if (!cartWrapper || !adoric || !adoric.trigger) {
  14. return null;
  15. }
  16. cartWrapper.addEventListener('click', function(event) {
  17. var paymentButton = event.target.closest('[class*="paymentButton"]');
  18. setTimeout(function() {
  19. if (checkCheckoutState() && paymentButton && window.adoricVars.cartInfo.sum > MIN_TOTAL_CART_SUM_LIMIT && window.adoricVars.cartInfo.sum <= MAX_TOTAL_CART_SUM_LIMIT && paymentButton && adoricVars.userInfo.deliveryPlanName == 'חבילת בסיס') {
  20. adoric.trigger(SHOW_CAMPAIGN_EVENT_NAME);
  21. }
  22. }, 1000);
  23. });
  24. }
  25. if (document.readyState === 'loading') {
  26. document.addEventListener('DOMContentLoaded', checkPaymentCampaign);
  27. } else {
  28. checkPaymentCampaign();
  29. }
  30. })();
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement