Advertisement
NFJMEDIA

Reserva - dataLayer

Jan 2nd, 2023
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- Google Tag Manager -->
  2. <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
  3. new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
  4. j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
  5. 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
  6. })(window,document,'script','dataLayer','GTM-5MCMDZD');</script>
  7. <!-- End Google Tag Manager -->
  8.  
  9. if (window.location.href === "https://app.cover.is/b59/book#/choose-dates") {
  10.   window.dataLayer = window.dataLayer || []
  11.   window.dataLayer.push({
  12.     'event': 'Choose-Dates',
  13.     'start_date': booking_object.date_arrival,
  14.     'end_date': booking_object.date_departure,
  15.   });
  16. }
  17.  
  18.  
  19. <script>
  20.   function confirmation_tag(booking_object) {
  21.     if (booking_object['booked_rooms'] && booking_object['booked_rooms'].length > 0) {
  22.       items = [];
  23.       var pagePath = location.href;
  24.       var pageTitle = 'Confirmation Page - Booking';
  25.  
  26.       booking_object['booked_rooms'].forEach((booked_room) => {
  27.         items.push({
  28.           id: booked_room.room['short_code'],
  29.           name: booked_room.room['name'],
  30.           quantity: booked_room.count,
  31.           price: booked_room.full_price
  32.         })
  33.       })
  34.       booking_object['booked_extras'].forEach((booked_extra) => {
  35.         items.push({
  36.           id: booked_extra.title,
  37.           name: booked_extra.title,
  38.           quantity: booked_extra.count,
  39.           price: booked_extra.price
  40.         })
  41.       })
  42. window.dataLayer = window.dataLayer || [];
  43. window.dataLayer.push({
  44.   event: 'purchase',        
  45.   ecommerce: {
  46.     currency: 'booking_object['currency']',
  47.     value: booking_object['amount'],                    
  48.     affiliation: 'Booking Factory',  
  49.     transaction_id: 'booking_object['token']',      
  50.     page_path": pagePath,    
  51.    page_title": pageTitle  
  52.     items:[{                      
  53.       item_name:'booked_room.room['name']',        
  54.       item_id: 'booked_room.room['short_code']',              
  55.       price: 'booked_room.full_price',                
  56.       item_brand: 'Herbergi',              
  57.       quantity: 'booked_room.count',  
  58.       start_date': booking_object.date_arrival,
  59.      end_date': booking_object.date_departure,
  60.         },{
  61.       item_name: 'booked_extra.title',
  62.       item_id: 'booked_extra.title',
  63.       price: 'booked_extra.price',
  64.       item_brand: 'Aukahlutir',
  65.       quantity: 'booked_extra.count'
  66.       start_date': booking_object.date_arrival,
  67.      end_date': booking_object.date_departure,
  68.     }},]
  69.   }
  70. });
  71.     }
  72.   }
  73. </script>
  74.  
  75.  
  76. function(){ var capturedText = document.querySelector("h1").innerText.trim(); return capturedText; }  // Room Name - Step 3 - Item Name
  77.  
  78. function(){ var capturedText = document.querySelector(".OfferOption__title").innerText.trim(); return capturedText; } // Offer available - Offer Name
  79.  
  80. function(){ var capturedText = document.querySelector(".OfferOption__price").innerText.match(/^.{4}(.*).{0}/i)[1].trim(); return capturedText; } // Item Price - Offer Price
  81.  
  82. function(){ var capturedText = document.querySelector(".OfferOption__price").innerText.match(/^(.*).{7}/i)[1].trim(); return capturedText; } // Item Currency
  83.  
  84.  
  85. // 1 - Veldu Dagsetningar
  86.       start_date': booking_object.date_arrival,
  87.      end_date': booking_object.date_departure,
  88. // 2 - Valið herbergi
  89.       function(){ var capturedText = document.querySelector(".selectedDatesAndOcc__occupancy").innerText.match(/^(.*).{9}/i)[1].trim(); return capturedText; } // Dates Selected
  90. // 3 - Valinn flokkur
  91.       function(){ var capturedText = document.querySelector("h1").innerText.trim(); return capturedText; }  // Room Name - Step 3 - Item Name
  92.  
  93. function(){ var capturedText = document.querySelector(".OfferOption__title").innerText.trim(); return capturedText; } // Offer available - Offer Name
  94.  
  95. function(){ var capturedText = document.querySelector(".OfferOption__price").innerText.match(/^.{4}(.*).{0}/i)[1].trim(); return capturedText; } // Item Price - Offer Price
  96.  
  97. function(){ var capturedText = document.querySelector(".OfferOption__price").innerText.match(/^(.*).{7}/i)[1].trim(); return capturedText; } // Item Currency
  98. // 4 - Skoða samantekt
  99. function(){ var capturedText = document.querySelector(".col-6-12.summaryRoom__title").innerText.trim(); return capturedText; } // Item Name
  100.  
  101. function(){ var capturedText = document.querySelectorAll(".lang__is>.container.summary-container>.summaryContentWrapper>.grid>.summaryControls.summaryControls__totals.col-6-12>.summaryTotalRow.summaryTotalRow__grandTotal>.summaryTotalRow__value")[0].innerText.trim(); return capturedText; } // Item Price
  102.  
  103. // 5 - Bæta við upplýsingum og greiðslu
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement