Écrit par Cédric Métairie
Dernière mise à jour : lundi 07 octobre 2024
Custom code
<script type="text/javascript">
function thaisBeStep(tracker) {
// Application Booking engine (https://INSTANCE.thais-hotel.com/direct-booking)
// Le tracker se déclenche à chaque fois qu'un utilisateur avance d'une étape
// Liste des tracker.send = ['Landing', 'Search', 'Add Room', 'Add Extra', 'Cart', 'Resume', 'Contact', 'payment']
// fonction appelée lors des événements tracker
// tracker = {
// i: 0,
// send: 'Landing',
// data: {
// booking_rooms: [
// {
// room_type_id: 8,
// rate_id: 52,
// price: 3,
// nb_persons: { adults: 2, children: 0, infants: 0 },
// },
// ],
// checkin: '2023-01-11',
// checkout: '2023-01-12',
// created_at: '2022-12-12T10:49:36+01:00',
// updated_at: '2022-12-12T10:49:45+01:00',
// lang: 'FR',
// },
// raw: {
// room_types: [
// {
// id: 8,
// label: 'QUINTUPLE',
// nb_persons_min: 1,
// nb_persons_max: 5,
// description: '<p>QUINT</p>',
// pictures: [],
// },
// ],
// rates: [
// {
// id: 58,
// label: 'STANDARD',
// description: '',
// rate_per_person: false,
// nb_persons_min: 1,
// nb_persons_max: 2,
// nb_adults_min: 1,
// nb_adults_max: 2,
// nb_days_for_lastminute: 0,
// nb_days_for_earlybooking: 0,
// deposit_rate_computed: 11.01,
// },
// ],
// },
// }
window.dataLayer = window.dataLayer || [];
const roomTypes = tracker.raw.room_types;
const rates = tracker.raw.rates;
const rooms = tracker.data.booking_rooms.map((m) => {
const room = roomTypes.find((f) => f.id === m.room_type_id);
return {
item_name: room.label,
item_id: room.id,
price: m.price,
item_brand: "Parc Sainte-Croix",
item_category: "Hébergement",
item_variant: m.nb_persons,
quantity: 1
}
});
let items = [];
if (tracker.send === "Landing") {
}
if (tracker.send === "Search") {
}
if (tracker.send === "Add Room") {
window.dataLayer.push({
event: "add_to_cart",
ecommerce: {
items: rooms,
},
});
}
}
function thaisBeSendReservation(reservation) {
// Application Booking engine (https://INSTANCE.thais-hotel.com/direct-booking)
// fonction appelée lors de l'envoie de la réservation
// Objet reservation //
// const reservation = {
// id: 2661,
// lang: "FR",
// checkin: "2023-01-09", // date checkin YYYY-MM-DD
// checkout: "2023-01-10", // date checkout YYYY-MM-DD
// total: 153.37,
// book: {
// // Donnée de la réservation + contact
// booking_rooms: [
// {
// extras: [
// {
// article_id: 676,
// date: "2023-01-27",
// label: "Café gourmand",
// quantity: 1,
// unit_price_incl: 13.37,
// },
// ],
// nb_persons: [{ adults: 2, children: 0, infants: 0 }],
// price: 140,
// rate_id: 32,
// room_type_id: 8,
// _id: "CYfZT7QqZI_ftBrNnf8zB",
// },
// ],
// checkin: "2023-01-25",
// checkout: "2023-01-27",
// comment: "",
// created_at: "2022-12-06T14:44:06+01:00",
// customer_address: "45 rue de sterne",
// customer_city: "MONTPELLIER",
// customer_civility_id: 1,
// customer_country: "FR",
// customer_email: "[email protected]",
// customer_firstname: "Cédric",
// customer_lastname: "Durand",
// customer_phone: "+33681238345",
// customer_zipcode: "34070",
// insurance_amount: 6.9,
// lang: "FR",
// language: "FR",
// payment_amount: 23.78,
// total_amount: 160.27,
// updated_at: "2022-12-06T14:44:12+01:00",
// },
// rooms: [
// // Détails des chambres réservées
// {
// category: "Super REAL Rate",
// id: 2661,
// name: "QUINTUPLE",
// price: 140,
// quantity: "1",
// sku: 8,
// },
// ],
// extras: [
// // Détails des extras réservés
// {
// category: "Café gourmand",
// id: 2661,
// name: "Café gourmand",
// price: 13.37,
// quantity: 1,
// sku: 676,
// },
// ],
// };
}
</script>
<script type="text/javascript">
function thaisCkdoStep(tracker) {
// Application bons cadeaux (https://INSTANCE.thais-hotel.com/ckdo)
// Le tracker se déclenche à chaque fois qu'un utilisateur avance d'une étape lors de l'achat d'un bon cadeau
// ETAPE 1 => saisie des informations et click sur suivant
// tracker = {
// amount: 50,
// buyer_email: '[email protected]',
// buyer_firstname: 'John',
// buyer_lastname: 'Doe',
// message: 'Message envoyé',
// receiver_email: '[email protected]',
// receiver_firstname: 'Jane',
// receiver_lastname: 'Doe'
// }
// ETAPE 2 => Paiement accepté
// tracker = {
// id: 40,
// amount: 50,
// buyer: 'John Doe',
// buyerEmail: '[email protected]',
// createdAt: '2022-12-14T10:33:12+01:00',
// maskedToken: 'CZ4****49K',
// message: 'Message envoyé',
// receiver: 'Jane Doe',
// receiverEmail: '[email protected]'
// }
}
</script>