Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 50 51 52 53 54 | 1x 1x 1x 1x 1x 1x 39x 39x 39x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 39x | import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root',
})
export class TrackingPixelService {
private baseScriptUrl = 'ads.travelaudience.com/js/ta.js';
injectPixel({
level,
language = 'en',
bookingId = '',
priceTo = '',
currency = '',
}: {
level: '1' | '6';
language?: string;
bookingId?: string;
priceTo?: string;
currency?: string;
}) {
const pixelCode: string[] = [
'var _ttq = _ttq || [];',
"_ttq.push(['_setAccount', '30000883']);",
"_ttq.push(['_setDataSource', 'av']);",
"_ttq.push(['_setProduct', '0']);",
`_ttq.push(['_setLevel', '${level}']);`,
`_ttq.push(['_setLanguage', '${language}']);`,
];
if (level === '6') {
pixelCode.push(
`_ttq.push(['_setBookingId','${bookingId}']);`,
`_ttq.push(['_setPriceTo','${priceTo}']);`,
`_ttq.push(['_setCurrency','${currency}']);`,
);
}
pixelCode.push("_ttq.push(['_track']);");
// Append tracking setup script
const setupScript = document.createElement('script');
setupScript.type = 'text/javascript';
setupScript.innerHTML = pixelCode.join('\n');
document.body.appendChild(setupScript);
// Append external pixel JS
const externalScript = document.createElement('script');
externalScript.type = 'text/javascript';
externalScript.src = `${location.protocol === 'https:' ? 'https://' : 'http://'}${this.baseScriptUrl}`;
document.body.appendChild(externalScript);
}
}
|