Advertisement
NikolayBezay

Bissell GTM tag that needs to send event to Adoric for recently viewed recommendation.

Sep 13th, 2023
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <script>
  2. (function() {
  3. function sendProductEventToAdoric() {
  4. var productId = document.querySelector('[data-productid]');
  5. if (productId && window.adoric && window.adoric.trigger) {
  6. productId = productId.getAttribute('data-productid');
  7. adoric.trigger("pageview", {
  8. type: "product",
  9. ids: productId,
  10. });
  11. }
  12. }
  13.  
  14. function waitAdoric() {
  15. if (window.adoric) {
  16. sendProductEventToAdoric();
  17. } else {
  18. document.addEventListener('adoric-loaded', function() {
  19. sendProductEventToAdoric();
  20. });
  21. }
  22. }
  23.  
  24. if (document.readyState === 'loading') {
  25. document.addEventListener('DOMContentLoaded', waitAdoric);
  26. } else {
  27. waitAdoric();
  28. }
  29. })();
  30. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement