Instant Quote Widget
const queryString = window.location.search;
const fullUrl = window.location.href;
const urlParams = new URLSearchParams(queryString);
const lang = urlParams.get(‘lang’);
const mod = urlParams.get(‘model’);
const loc = urlParams.get(‘location’)
const campaign = urlParams.get(‘campaign’)
const fbclid = urlParams.get(‘fbclid’)
const gclid = urlParams.get(‘gclid’)
const device = urlParams.get(‘device’)
let string = ”;
let el = window.document.getElementById(‘widget_q2lbtrG0p0bSbDa02Ymp’);
if(mod){
let dataSrc = el.getAttribute(“data-src”);
if(!dataSrc){
dataSrc = el.getAttribute(“src”)
if(loc){
el.setAttribute(‘src’,dataSrc+’&model=’+mod+’&location=’+loc)
} else{
el.setAttribute(‘src’,dataSrc+’&model=’+mod)
}
}else{
if(loc){
el.setAttribute(‘data-src’,dataSrc+’&model=’+mod+’&location=’+loc);
} else{
el.setAttribute(‘data-src’,dataSrc+’&model=’+mod);
}
}
}
if(campaign) string = string + ‘&campaign=’+campaign;
if(fbclid) string = string + ‘&fbclid=’+fbclid;
if(gclid) string = string + ‘&gclid=’+gclid;
if(device) string = string + ‘&device=’+device;
if(lang) string = string + ‘&lang=’+lang;
if(campaign || fbclid || gclid || device || lang){
let lastSrc = el.getAttribute(“data-src”);
if(!lastSrc) {
lastSrc = el.getAttribute(“src”)
el.setAttribute(‘src’,lastSrc+string);
}else{
el.setAttribute(‘data-src’,lastSrc+string);
}
}
if(fullUrl){
let lastSrc = el.getAttribute(“data-src”);
if(!lastSrc) {
lastSrc = el.getAttribute(“src”)
el.setAttribute(‘src’,lastSrc+’&from=’+fullUrl);
}else{
el.setAttribute(‘data-src’,lastSrc+’&from=’+fullUrl);
}
}
window.addEventListener(‘message’, function (e) {
if (e.data.indexOf(‘WIDGET_CONTENT_CHANGED’) === 0) {
window.document.getElementById(‘widget_q2lbtrG0p0bSbDa02Ymp’).style.height = e.data.split(‘|’)[1];
}
}, false);