Test


<!-- TuriTop Event snippet for Purchase URL conversion page -->
<script>
function turitop_booking_system_thank_page() {}
turitop_booking_system_thank_page.prototype.init = function(){
/* ############################################
####      Parameter from google ads     ####
############################################ */
this.send_to = []; this.send_to.push(  );    /* ############################################ */
/* ############################################ */
/* ############################################
####      Parameter from google analytics 4    ####
############################################ */  this.ga4 = G-CC8GWT0CWP;/* ############################################ */
this.current_url = window.location.search;
this.current_url_params = new URLSearchParams( this.current_url );
/* ############################################
####      Parameter from facebook ads     ####
############################################ */ this.fbpixel = ;    if (typeof this.fbpixel === 'undefined' || typeof this.fbpixel === null || 0 === this.fbpixel.length){
this.fbpixel = this.current_url_params.get( 'fbpixel' );
} 
this.sPageURL = decodeURIComponent( window.location.search.substring( 1 ) );
this.currency = this.current_url_params.get( 'currency' );
this.base_url = this.current_url_params.get( 'd' );
this.lang = this.current_url_params.get( 'lang' );
this.csid = this.current_url_params.get( 'csid' );
this.company_name = this.current_url_params.get( 'company_name' );
this.product_short_id = this.current_url_params.get( 'product_short_id' );
this.product_name = this.current_url_params.get( 'product_name' );
this.shopping_cart_id = this.current_url_params.get( 'shopping_cart_id' );
this.multiclient_hash = this.current_url_params.get( 'multi_client_hash' );
this.totals = 0;
this.transaction_id = '';
this.tickets = [];
this.events();
};
turitop_booking_system_thank_page.prototype.events = function(){
this.get_totals();
this.get_transaction_id();
this.send_purchase_event_to_google_ads();
this.send_purchase_event_to_facebook_ads();
this.send_purchase_event_to_google_analytics_4();
};
turitop_booking_system_thank_page.prototype.getUrlParameter = function( sParam ){
var array =[]
var sURLVariables = this.sPageURL.split('&');
for ( var i = 0; i < sURLVariables.length; i++ ) {
var sParameterName = sURLVariables[ i ].split( '=' );
if ( sParameterName[ 0 ] == sParam ) {
array.push( sParameterName[ 1 ] );
}
}
return array;
};
turitop_booking_system_thank_page.prototype.get_totals = function(){
var total = this.getUrlParameter( 'total[]' );
if ( ! total || 0 === total.length || typeof total == 'undefined' ){
this.total = this.current_url_params.get( 'total' );
}
else{
var out = parseFloat( 0 );
for ( var i in total ) {
out = out + parseFloat( total[i] );
}
this.total = out;
}
};
turitop_booking_system_thank_page.prototype.get_transaction_id = function(){
var booking_id = this.getUrlParameter( 'booking_id[]' );
if ( ! booking_id || 0 === booking_id.length || typeof booking_id == 'undefined' ){
this.transaction_id = this.current_url_params.get( 'booking_id' );
var ticket = {
booking_id: this.transaction_id,
url: this.base_url + this.current_url_params.get( 'link' ),
price: this.total
}
this.tickets.push( ticket );
}
else{
var link = this.getUrlParameter( 'link[]' );
var price = this.getUrlParameter( 'price[]' );
var out = '';
var cart_id = '';
var multiclient = '';
if ( this.shopping_cart_id || 0 != this.shopping_cart_id.length || typeof this.shopping_cart_id != 'undefined' ){
cart_id = this.shopping_cart_id;
}
if ( this.multiclient_hash || 0 != this.multiclient_hash.length || typeof this.multiclient_hash != 'undefined' ){
multiclient = this.multiclient_hash;
}
for ( var i in booking_id ) {
var ticket = {
booking_id: booking_id[ i ],
url: this.base_url + link[ i ],
price: price[ i ],
cart_id: cart_id,
multiclient: multiclient
}
this.tickets.push( ticket );
out += "-Booking-" + booking_id[ i ];
this.buttons = [];
}
this.transaction_id = out;
}
};
turitop_booking_system_thank_page.prototype.send_purchase_event_to_google_ads = function(){
for ( var i in this.send_to ) {
gtag('event', 'conversion', {
'send_to': this.send_to[ i ],
'value': this.total,
'currency': this.currency,
'transaction_id': this.transaction_id
});
}
};
turitop_booking_system_thank_page.prototype.send_purchase_event_to_facebook_ads = function(){
if ( 0 != this.fbpixel.length ){
console.log( 'this.fbpixel -> ' + this.fbpixel );
fbq( 'track', 'Purchase', {
'value': this.total,
'currency': this.currency
});
}
};
turitop_booking_system_thank_page.prototype.send_purchase_event_to_google_analytics_4 = function(){
if ( 0 != this.ga4.length ){
console.log( 'this.ga4 -> ' + this.ga4 );
var tid = '';    
gtag('config', this.ga4 );
for ( var i in this.tickets ) {
if ( this.tickets[i].multiclient || 0 != this.tickets[i].multiclient.length || typeof this.tickets[i].multiclient != 'undefined' ){
tid = this.tickets[i].multiclient;
} else if ( this.tickets[i].cart_id || 0 != this.tickets[i].cart_id.length || typeof this.tickets[i].cart_id != 'undefined'){
tid = this.tickets[i].cart_id;
}  else {
tid = this.tickets[i].booking_id;
}
gtag('event', 'purchase', {
'transaction_id': tid, //IF shopping cart, shopping cart id, IF multiclient, multiclient hash, ELSE, booking number
'currency': this.currency, // local currency code
'value': this.total, //Valor total
'items': [
{ //one item per product bought
'item_id': this.product_short_id, //Short_id product
'item_name': this.product_name, //Nombre del producto en idioma original
'item_brand': this.csid + '-' + this.company_name, //company short ID + nombre empresa. En caso de reventa, usar datos del proveedor
'item_category': this.lang, //Language
'price': this.tickets[i].price, //Valor pagado por producto comprado, ejemplo 9.99
'currency': this.currency, // local currency code product
'quantity': 1 //Aquí siempre se pone 1, aunque se hayan comprado varios tipos de tickets
}
]
});
} 
}
};
turitop_booking_system_thank_page.prototype.fill_tickets = function(){
for ( var i in this.tickets ) {
var html = '<div class="turitop_thank_you_page_ticket">';
html = html + '<div class="turitop_thank_you_page_ticket_booking_id">';
html = html + this.tickets[i].booking_id;
html = html + '</div>';
html = html + '<div class="turitop_thank_you_page_ticket_url">';
html = html + '<a href="' + this.tickets[i].url + '" target="_blank"> <button> Download/Print </button> </a>';
html = html + '</div>';
html = html + '</div>';
document.getElementById( "turitop_thank_you_page_tickets" ).insertAdjacentHTML( "afterbegin", html );
}
if ( this.tickets.length > 1 )
var tickets_title = "Your reference numbers:";
else
var tickets_title = "Your reference number:";
document.getElementById( "turitop_thank_you_page_tickets" ).insertAdjacentHTML( "afterbegin", '<div class="turitop_thank_you_page_tickets_title">' + tickets_title + '</div>' );
};
var turitop_booking_system_thank_page_instance = new turitop_booking_system_thank_page();
turitop_booking_system_thank_page_instance.init();
</script>
<style>
.turitop_thank_you_page_wrap{
display: block;
width: 100%;
text-align: center;
}
.turitop_thank_you_page_wrap .turitop_thank_you_page_red_dark{
color: #900;
}
.turitop_thank_you_page_tickets{
margin: 20px 0;
}
.turitop_thank_you_page_tickets_title{
font-size: bold;
margin-bottom: 8px;
}
.turitop_thank_you_page_wrap .turitop_thank_you_page_ticket{
display: inline-flex;
justify-content: center;
align-items: center;
margin-bottom: 5px;
flex-wrap: wrap;
}
.turitop_thank_you_page_wrap .turitop_thank_you_page_ticket_booking_id{
display: inline-block;
background: #f2f2f2;
border: 1px solid #b3b3b3;
border-radius: 2px;
font-size: 34px;
font-weight: 700;
padding: 10px 15px;
margin: 5px;
}
.turitop_thank_you_page_wrap .turitop_thank_you_page_ticket_url{
margin: 5px;
}
</style>
<div class="turitop_thank_you_page_wrap">
<div class="turitop_thank_you_page_title">
Thank you!
</div>
<div id="turitop_thank_you_page_tickets" class="turitop_thank_you_page_tickets">
</div>
<div class="turitop_thank_you_page_message">
<p>
Important: For confirmation and booking details please check your email, including the SPAM folder. It might take a few minutes to arrive.
</p>
<p class="turitop_thank_you_page_red_dark">
If you don't receive any confirmation email in less than 30 minutes, please contact us, the booking could not be confirmed.
</p>
</div>
</div>
<script>
turitop_booking_system_thank_page_instance.fill_tickets();
</script>