function turitop_booking_system_thank_page() {}
turitop_booking_system_thank_page.prototype.init = function(){
this.send_to = []; this.send_to.push( ‘AW-353777577/XlRHCInO87gcEKnv2KgB’ );
this.ga4 = ‘ ‘;
this.gtm = ‘ ‘;
this.current_url = window.location.search;
this.current_url_params = new URLSearchParams( this.current_url );
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( ‘multiclient_hash’ );
this.client_name = this.current_url_params.get( ‘client_name’ );
this.client_email = this.current_url_params.get( ‘client_email’ );
this.client_names = this.current_url_params.get( ‘client_name[]’ );
this.client_emails = this.current_url_params.get( ‘client_email[]’ );
this.buyer_email = this.current_url_params.get( ‘buyer_email’ );
this.payment_link = this.current_url_params.get( ‘payment_link’ );
this.totals = 0;
this.transaction_id = ”;
this.redsys_merchant_parameters = this.current_url_params.get( ‘Ds_MerchantParameters’ );
this.name_commerce = ‘ ‘;
this.commerce_url = ‘ ‘;
this.booking_short_id = this.getUrlParameter( ‘booking_id[]’ );
if ( typeof this.booking_short_id === ‘undefined’ || this.booking_short_id === null || 0 === this.booking_short_id.length ) {
this.booking_short_id = this.current_url_params.get( ‘booking_id’ );
}
this.product_description = this.current_url_params.get( ‘product_description’ );
this.tickets = [];
this.events();
};
turitop_booking_system_thank_page.prototype.events = function(){
this.get_totals();
this.get_transaction_id();
// —- GUARD: solo disparar conversiones si hay una RESERVA REAL —-
// Evita conversiones falsas cuando /thank-you/ se abre directamente,
// se recarga, o lo visita un bot (sin parámetros de reserva en la URL).
var ttTotal = parseFloat( this.total );
var ttHasBooking = !!this.transaction_id && String( this.transaction_id ).length > 0;
if ( isNaN( ttTotal ) || ttTotal c.charCodeAt(0)));
return new TextDecoder(‘utf-8’).decode(bytes);
};
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 != null ){
cart_id = this.shopping_cart_id;
multiclient = '';
}
if ( this.multiclient_hash != null ){
multiclient = this.multiclient_hash;
cart_id = '';
}
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(){
if (typeof gtag === '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 (typeof fbq === 'function') {
if ( typeof this.fbpixel != 'undefined' || 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 (typeof gtag === 'function') {
if ( 0 != this.ga4.length ){
var tid = '';
for ( var i in this.tickets ) {
if ( this.tickets[i].cart_id != '' ){
tid = this.tickets[i].cart_id;
}
if ( this.tickets[i].multiclient != '' ){
tid = this.tickets[i].multiclient;
}
if ( typeof this.tickets[i].multiclient == 'undefined' || typeof this.tickets[i].cart_id == 'undefined' ) {
tid = this.tickets[i].booking_id;
}
gtag('event', 'purchase', {
'transaction_id': tid,
'currency': this.currency,
'value': this.total,
'items': [
{
'item_id': this.product_short_id,
'item_name': this.product_name,
'item_brand': this.csid + '-' + this.company_name,
'item_category': this.lang,
'price': this.tickets[i].price,
'currency': this.currency,
'quantity': 1
}
]
});
}
}
}
};
turitop_booking_system_thank_page.prototype.send_purchase_event_to_google_tag_manager = function(){
if ( 0 != this.gtm.length ){
var tid = '';
for ( var i in this.tickets ) {
if ( this.tickets[i].cart_id != '' ){
tid = this.tickets[i].cart_id;
}
if ( this.tickets[i].multiclient != '' ){
tid = this.tickets[i].multiclient;
}
if ( typeof this.tickets[i].multiclient == 'undefined' || typeof this.tickets[i].cart_id == 'undefined' ) {
tid = this.tickets[i].booking_id;
}
dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: “purchase”,
ecommerce: {
transaction_id: tid,
currency: this.currency,
value: this.total,
items: [
{
item_id: this.product_short_id,
item_name: this.product_name,
item_brand: this.csid + '-' + this.company_name,
item_category: this.lang,
price: this.tickets[i].price,
currency: this.currency,
quantity: 1
}
]
}
});
}
}
};
turitop_booking_system_thank_page.prototype.fill_tickets = function(){
for ( var i in this.tickets ) {
var html = '
‘;
html = html + ‘
‘;
html = html + this.tickets[i].booking_id;
html = html + ‘
‘;
html = html + ‘
‘;
html = html + ‘‘; html = html + ‘
‘;
html = html + ‘
‘;
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:”;
var name = ”;
var email = ”;
if ( this.client_name != null ) {
var name = this.client_name;
}
if ( this.client_names != null ) {
var name = this.client_names;
}
if ( this.client_email != null) {
var email = this.client_email;
}
if ( this.client_emails != null) {
var email = this.client_emails;
}
if ( this.booking_short_id != null ) {
html_booking_data = ‘