templates/default/components/atoms/econda-tracking/econda-tracking.html.twig line 1

Open in your IDE?
  1. <script>
  2. window.econda = {
  3. onReady: [], ready: function (f) {
  4. this.onReady.push(f);
  5. }
  6. };
  7. let haseSend = false;
  8. {% block startOfScript %}
  9. {% endblock %}
  10. {% block default %}
  11. window.emos3 = window.emos3 || {
  12. defaults : {
  13. content: window.location.pathname,
  14. siteid: '{{ 'econda_site_id'|trans }}',
  15. pageId: '{{ page_type_tracking |default(page_type| default('other')) }}',
  16. 'tecdata': [[null, '{{ page_type_tracking |default(page_type| default('other')) }}']],
  17. },
  18. stored : [],
  19. send : function(p){this.stored.push(p);}
  20. };
  21. {% endblock %}
  22. {% block send %}
  23. window.emos3InitialSend = function() {
  24. if (!haseSend) {
  25. const econdaSend = {{ econdaSend|default|json_encode|raw }};
  26. if (econdaSend !== "") {
  27. window.emos3.send(econdaSend);
  28. } else {
  29. window.emos3.send({});
  30. }
  31. haseSend = true;
  32. }
  33. }
  34. {% endblock %}
  35. document.addEventListener('econdaClickEvent', function (event) {
  36. let data = {
  37. name: event.detail.name,
  38. type: 'c_add',
  39. pid: event.detail.sku,
  40. sku: event.detail.sku,
  41. price: event.detail.price,
  42. group: event.detail.category,
  43. count: event.detail.quantity,
  44. var1: null,
  45. var2: null,
  46. var3: null
  47. };
  48. window.emos3.send({
  49. ec_Event: [
  50. data
  51. ]
  52. });
  53. });
  54. document.addEventListener('loginEvent', function (event) {
  55. if(event.detail.email !== '') {
  56. window.emos3.send({login: [event.detail.email, event.detail.hasError ?? 1]});
  57. }
  58. })
  59. document.addEventListener('phainaInterviewIdAdded', function (event) {
  60. if(event.detail.interviewId !== '') {
  61. econdaSend = {};
  62. econdaSend.productfinderid = [[event.detail.interviewId]];
  63. window.emos3.send(econdaSend);
  64. }
  65. })
  66. </script>