Yes, this can be achieved using our JavaScript callback feature.
Here is an example of pixel tracking:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
<script> function customHotelCallback(data) { //console.log(data); //Now handle the posible events comming if(data.event == 'page_results') { var sjrn = {}; var sjrn_id = 1234; sjrn.hc1 = "Town"; sjrn.hs1 = "Country"; sjrn.hpr = "Hotel name"; sjrn.et = "hs"; sjrn.hd1 = booking.arrivalDate; // NOTE: if not in yyyy-mm-dd format, please contact your Sojern Act Manager sjrn.hd2 = booking.departureDate; sjrn.t = booking.totalAdults; sjrn.hr = Math.ceil(booking.totalAdults/2); // Guessing number of double rooms (not really available) sjrn.cid = sjrn.hd1+"|"+sjrn.hd2+"|"+sjrn.t+"|"+sjrn.hr+"|"+sjrn.hpr; var sjrn_s = "https://beacon.sojern.com/pixel/p/"+sjrn_id+"?"; for (property in sjrn) { sjrn_s += property + "=" + encodeURIComponent(sjrn[property]) + "&"; } sjrn_s = sjrn_s.slice(0,-1); var pl = document.createElement('script'); pl.type = 'text/javascript'; pl.async = true; pl.src = sjrn_s; (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(pl); } if(data.event == 'booking_completed') { var pl = document.createElement('script'); pl.type = 'text/javascript'; pl.async = true; pl.src = 'https://beacon.sojern.com/pixel/p/1234?cid='+booking.bookingId+'|'+booking.totalPrice+'|'+booking.arrivalDate+'|'+booking.departureDate+'|&hconfno='+booking.bookingId+'&hp='+booking.totalPrice+'&hd1='+booking.arrivalDate+'&hd2='+booking.departureDate+''; console.log(JSON.stringify(booking)); console.log(pl.src); (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(pl); } } </script> <script src="https://secured.sirvoy.com/widget/sirvoy.js" async="" type="text/javascript" data-callback="customHotelCallback" data-form-id="**CHANGE-THIS**"></script> |