PZ Advisors is an innovative consulting firm focused on strategic performance and sustainable growth, combining advanced business solutions with well-being and productivity optimization. We provide specialized services in technology, digital marketing, and high-performance strategies.
What sets us apart is our integrated approach, merging Business Advisory and Wellness Advisory to help individuals and businesses achieve peak efficiency, growth, and quality of life.
At PZ Advisors, we are committed to helping businesses grow and individuals thrive. Whether you need strategic guidance for your company, technology consulting, or high-performance solutions, we’re here to help.
📩 Get in touch today! Let’s discuss how we can support your goals and drive your success. Fill out the form, and our team will reach out to you as soon as possible.
🚀 Let’s build the future together!
Contact us
/**
* PZ Advisors — GOT Universal Controller
* Versão: v1.3.2
* Autor: PZ Advisors
* Data: 2026-05-18 (Europe/Lisbon)
*
* DELTA v1.3.1 → v1.3.2 (Fix Race Condition __PZ assíncrono + Gates P0)
* -------------------------------------------------------------------
* [FIX-2] Race condition: __PZ é assíncrono (Firebase auth).
* main() directo em body_end encontrava __PZ null →
* getPageBucket() null → saída silenciosa sem eventos.
* Substituído por waitForPZ(20×200ms = max 4s) no ENTRY POINT.
*
* [GATE-1] Idempotência: didInit guard + startOnce(reason).
* Garante main() executa uma única vez por pageview,
* mesmo se o script for injectado duas vezes.
* Evento diagnóstico: pz_got_u_init_duplicate_blocked.
*
* [GATE-2] Timeout observável: se __PZ.pageType não aparecer em 4s,
* emite pz_got_u_init_timeout para QA/Tracking.
* Falha deixa de ser silenciosa.
*
* Aprovado: Gemini P0 ✅ | ChatGPT P0 ✅ (ae88613e)
*/
(function (w, d) {
'use strict';
var SCRIPT_VERSION = '1.3.2';
var PRE_PROMPT_DELAY_MS = 2000;
var MAX_WAIT_GSI_MS = 8000;
var COOLDOWN_MS = 20 * 60 * 1000;
var SCROLL_THRESHOLDS = { lander: 0.50, presell: 0.40 };
var RATES = {
lander: 0.50,
presell: 0.40,
bridge: 0.00,
checkout: 0.00,
'default': 0.00
};
var SS_SAMPLED = 'pz_got_u_sampled';
var LS_LAST_SHOWN = 'pz_got_u_shown';
var LS_AUTHED = 'pz_got_u_authed';
function dl(obj) { try { (w.dataLayer = w.dataLayer || []).push(obj); } catch (e) {} }
var ls = {
get: function (k) { try { return localStorage.getItem(k); } catch (e) { return null; } },
set: function (k, v) { try { localStorage.setItem(k, v); return true; } catch (e) { return false; } }
};
var ss = {
get: function (k) { try { return sessionStorage.getItem(k); } catch (e) { return null; } },
set: function (k, v) { try { sessionStorage.setItem(k, v); return true; } catch (e) { return false; } }
};
function pzReadPageGOTConfig() {
try {
var cfg = w.PZ_CONFIG;
if (!cfg || !cfg.pages) return null;
var path = (location.pathname || '/').replace(/\/+$/, '') || '/';
var pageCfg = cfg.pages[path];
if (!pageCfg) return null;
if (pageCfg.got_config === false) return null;
var mode = String(pageCfg.got_mode || '').toLowerCase();
if (!mode || mode === 'none') return null;
if (mode !== 'soft' && mode !== 'hard') {
dl({ event: 'pz_got_u_skip', reason: 'invalid_got_mode', mode: mode, v: SCRIPT_VERSION });
return null;
}
var scroll = typeof pageCfg.got_scroll === 'number' ? pageCfg.got_scroll : null;
if (scroll !== null && (scroll < 0 || scroll > 100)) {
dl({ event: 'pz_got_u_skip', reason: 'invalid_got_scroll', scroll: scroll, v: SCRIPT_VERSION });
return null;
}
return { mode: mode, scroll: scroll, text: pageCfg.got_text || null, sub: pageCfg.got_sub || null, path: path };
} catch (e) {
dl({ event: 'pz_got_u_error', reason: 'page_config_read_fail', msg: String(e.message || '').slice(0, 60), v: SCRIPT_VERSION });
return null;
}
}
function pzReadOfferGOTConfig() {
try {
var cfg = w.PZ_CONFIG;
if (!cfg || !cfg.offers) return null;
var offerId = null;
var qs = new URLSearchParams(location.search);
var qsOffer = qs.get('offer_id');
if (qsOffer && cfg.offers[qsOffer]) { offerId = qsOffer; }
if (!offerId) {
var chosenProduct = ss.get('pz_chosen_product');
if (chosenProduct) {
var keys = Object.keys(cfg.offers);
for (var i = 0; i < keys.length; i++) {
var o = cfg.offers[keys[i]];
if (keys[i] === chosenProduct || (o.offer_name && o.offer_name.indexOf(chosenProduct) !== -1)) {
offerId = keys[i]; break;
}
}
}
}
if (!offerId) return null;
var offerCfg = cfg.offers[offerId];
if (!offerCfg) return null;
var hasGOT = (offerCfg.got_mode || offerCfg.got_skip_if_auth !== undefined);
if (!hasGOT) return null;
return {
offer_id: offerId,
got_mode: offerCfg.got_mode || null,
got_skip_if_auth: offerCfg.got_skip_if_auth !== undefined ? !!offerCfg.got_skip_if_auth : null
};
} catch (e) { return null; }
}
function getPageBucket() {
var pz = w.__PZ; if (!pz) return null;
var t = String(pz.pageType || '').toLowerCase();
if (t === 'lander' || t === 'endocap-method' || t.indexOf('virility') === 0 || t === 'home') return 'lander';
if (t === 'presell' || t.indexOf('presell') !== -1) return 'presell';
if (t === 'bridge') return 'bridge';
if (t === 'checkout') return 'checkout';
return 'default';
}
function isEligible(bucket) {
if (!RATES[bucket]) return false;
if (ls.get(LS_AUTHED) === '1') {
dl({ event: 'pz_got_u_skip', reason: 'already_authed', bucket: bucket, v: SCRIPT_VERSION });
return false;
}
var pz = w.__PZ;
var uid = (pz && pz.userId) ? String(pz.userId) : '';
if (uid && uid.indexOf('usr_') !== 0 && uid.length > 5) {
ls.set(LS_AUTHED, '1');
dl({ event: 'pz_got_u_skip', reason: 'uid_is_sub', bucket: bucket });
return false;
}
var lastShown = ls.get(LS_LAST_SHOWN);
if (lastShown) {
var elapsed = Date.now() - (new Date(lastShown)).getTime();
if (elapsed < COOLDOWN_MS) {
dl({ event: 'pz_got_u_skip', reason: 'cooldown', bucket: bucket, elapsed_min: Math.round(elapsed / 60000) });
return false;
}
}
return true;
}
function isEligibleOfferLayer(offerCfg) {
if (!offerCfg) return true;
if (offerCfg.got_skip_if_auth === true && ls.get(LS_AUTHED) === '1') {
dl({ event: 'pz_got_u_skip', reason: 'offer_skip_if_auth', offer_id: offerCfg.offer_id, v: SCRIPT_VERSION });
return false;
}
return true;
}
function isITPLikely() {
var ua = navigator.userAgent || '';
return /Safari/i.test(ua) && !/Chrome|Chromium|CriOS|FxiOS|EdgA/i.test(ua);
}
function hasConsent() {
try {
if (w.CookieYes && typeof w.CookieYes.consent === 'function') {
var c = w.CookieYes.consent();
return !!(c && (c.analytics || c.marketing));
}
var dl_ = w.dataLayer || [];
for (var i = dl_.length - 1; i >= 0; i--) {
var e = dl_[i];
if (e && e.analytics_storage) return e.analytics_storage === 'granted';
}
if (w.__cookieyes && w.__cookieyes.categories) {
return !!(w.__cookieyes.categories.analytics || w.__cookieyes.categories.marketing);
}
} catch (e) {}
return false;
}
function waitForGSI() {
return new Promise(function (resolve, reject) {
var deadline = Date.now() + MAX_WAIT_GSI_MS;
var timer = setInterval(function () {
if (w.google && w.google.accounts && w.google.accounts.id) { clearInterval(timer); resolve(w.google); }
if (Date.now() > deadline) { clearInterval(timer); reject(new Error('gsi_timeout')); }
}, 200);
});
}
function getClientId() {
var cfg = w.PZ_CONFIG;
if (cfg && cfg.api && cfg.api.google_client_id) return cfg.api.google_client_id;
return null;
}
function hideAnchor() {
var el = d.getElementById('pz-onetap-anchor');
if (el) el.style.display = 'none';
}
function showHardModeButton(googleApi, clientId, bucket) {
var anchor = d.getElementById('pz-onetap-anchor');
if (!anchor) return;
try {
googleApi.accounts.id.renderButton(anchor, { type: 'standard', shape: 'rectangular', theme: 'outline', text: 'signin_with', size: 'large', locale: 'en' });
anchor.style.display = 'block';
dl({ event: 'pz_got_u_hard_mode_shown', bucket: bucket, itp: isITPLikely() });
} catch (e) {
dl({ event: 'pz_got_u_error', reason: 'hard_mode_render_fail', bucket: bucket });
}
}
function handleNotification(notification, googleApi, clientId, bucket) {
var momentType = notification.getMomentType ? notification.getMomentType() : '';
var skipReason = notification.getSkippedReason ? notification.getSkippedReason() : '';
var dismissReason = notification.getDismissedReason ? notification.getDismissedReason() : '';
dl({ event: 'pz_got_u_notification', moment_type: momentType, skipped_reason: skipReason, dismissed_reason: dismissReason, bucket: bucket });
if (notification.isSkippedMoment && notification.isSkippedMoment()) {
if (skipReason === 'issuing_failed' || skipReason === 'opt_out_or_no_session' || isITPLikely()) {
showHardModeButton(googleApi, clientId, bucket);
}
}
if (notification.isDismissedMoment && notification.isDismissedMoment()) {
ss.set(SS_SAMPLED, 'no');
ls.set(LS_LAST_SHOWN, new Date().toISOString());
hideAnchor();
}
}
function sendGuide(userId) {
return fetch('https://api.pzadvisors.com/api/send-guide', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ user_id: userId }) })
.then(function (res) { return res.json(); })
.then(function (data) { dl({ event: 'pz_got_u_guide_sent', ok: !!data.ok }); })
.catch(function (err) { dl({ event: 'pz_got_u_guide_error', reason: String(err.message || '').slice(0, 60) }); });
}
function handleCredential(response, bucket) {
var credential = response && response.credential;
if (!credential) { dl({ event: 'pz_got_u_error', reason: 'no_credential', bucket: bucket }); return Promise.resolve(); }
dl({ event: 'pz_got_u_credential_received', bucket: bucket });
return fetch('https://api.pzadvisors.com/auth/google', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ credential: credential }) })
.then(function (res) { if (!res.ok) throw new Error('auth_http_' + res.status); return res.json(); })
.then(function (data) {
if (!data.ok || !data.user_id) throw new Error('auth_no_user_id');
var pz = w.__PZ;
if (pz && typeof pz.upgradeUserId === 'function') pz.upgradeUserId(data.user_id);
ls.set(LS_AUTHED, '1');
ls.set(LS_LAST_SHOWN, new Date().toISOString());
hideAnchor();
dl({ event: 'pz_got_u_authed', bucket: bucket, uid_prefix: String(data.user_id || '').slice(0, 6), email_domain: (data.email || '').split('@')[1] || '' });
var guidePromise = (bucket === 'lander') ? sendGuide(data.user_id) : Promise.resolve();
return guidePromise.then(function () { dl({ event: 'pz_got_u_post_auth', bucket: bucket, action: 'none' }); });
})
.catch(function (err) { dl({ event: 'pz_got_u_error', reason: String(err.message || '').slice(0, 80), bucket: bucket }); });
}
function firePrompt(bucket, gotMode) {
var clientId = getClientId();
if (!clientId) { dl({ event: 'pz_got_u_error', reason: 'no_client_id', bucket: bucket }); return; }
waitForGSI()
.then(function (googleApi) {
if (!hasConsent()) { dl({ event: 'pz_got_u_skip', reason: 'consent_denied', bucket: bucket }); return; }
if (gotMode === 'hard') { dl({ event: 'pz_got_u_hard_mode_direct', bucket: bucket }); showHardModeButton(googleApi, clientId, bucket); return; }
googleApi.accounts.id.initialize({
client_id: clientId,
callback: function (response) { handleCredential(response, bucket); },
auto_select: true, cancel_on_tap_outside: true, context: 'use',
itp_support: true, use_fedcm_for_prompt: true,
moment_callback: function (notification) { handleNotification(notification, googleApi, clientId, bucket); }
});
googleApi.accounts.id.prompt(function (notification) { handleNotification(notification, googleApi, clientId, bucket); });
dl({ event: 'pz_got_u_prompt_fired', bucket: bucket, itp_likely: isITPLikely(), got_mode: gotMode || 'soft', v: SCRIPT_VERSION });
})
.catch(function (err) { dl({ event: 'pz_got_u_error', reason: String(err.message || '').slice(0, 80), bucket: bucket }); });
}
function onSentinelVisible(bucket, gotMode, dataDriven) {
dl({ event: 'pz_got_u_trigger_reached', bucket: bucket, got_mode: gotMode || 'soft', data_driven: !!dataDriven, v: SCRIPT_VERSION });
var cached = ss.get(SS_SAMPLED);
if (cached === 'no') { dl({ event: 'pz_got_u_skip', reason: 'sampled_out_cached', bucket: bucket }); return; }
var sampled;
if (cached === 'yes') {
sampled = true;
} else {
var rate = dataDriven ? 1.0 : (RATES[bucket] || 0);
sampled = (Math.random() < rate);
var written = ss.set(SS_SAMPLED, sampled ? 'yes' : 'no');
if (!written) { dl({ event: 'pz_got_u_skip', reason: 'storage_write_fail', bucket: bucket }); return; }
dl({ event: 'pz_got_u_sampled', bucket: bucket, rate: rate, result: sampled ? 'in' : 'out' });
}
if (!sampled) return;
var lsWritten = ls.set(LS_LAST_SHOWN, new Date().toISOString());
if (!lsWritten) { dl({ event: 'pz_got_u_skip', reason: 'ls_write_fail', bucket: bucket }); return; }
setTimeout(function () { firePrompt(bucket, gotMode); }, PRE_PROMPT_DELAY_MS);
}
function setupScrollTrigger(bucket, scrollPct, gotMode, dataDriven) {
if (scrollPct === 0) {
dl({ event: 'pz_got_u_scroll_watch', bucket: bucket, threshold_pct: 0, sentinel_top_px: 0, got_mode: gotMode, data_driven: !!dataDriven, v: SCRIPT_VERSION });
setTimeout(function () { onSentinelVisible(bucket, gotMode, dataDriven); }, 500);
return;
}
var threshold = scrollPct !== null ? scrollPct / 100 : SCROLL_THRESHOLDS[bucket];
if (!threshold) return;
function placeSentinel() {
var bodyHeight = Math.max(d.body ? d.body.scrollHeight : 0, d.documentElement.scrollHeight || 0);
var viewH = w.innerHeight || d.documentElement.clientHeight || 600;
if (bodyHeight <= viewH * 1.2) {
dl({ event: 'pz_got_u_skip', reason: 'short_page_no_scroll_gate', bucket: bucket, body_px: bodyHeight, view_px: viewH });
return;
}
var sentinelTop = Math.round(bodyHeight * threshold);
var sentinel = d.createElement('div');
sentinel.setAttribute('data-pz-got-sentinel', '1');
sentinel.style.cssText = 'position:absolute;left:0;top:' + sentinelTop + 'px;width:1px;height:1px;pointer-events:none;visibility:hidden;';
try { d.body.appendChild(sentinel); } catch (e) {
dl({ event: 'pz_got_u_error', reason: 'sentinel_append_fail', bucket: bucket }); return;
}
dl({ event: 'pz_got_u_scroll_watch', bucket: bucket, threshold_pct: Math.round(threshold * 100), sentinel_top_px: sentinelTop, got_mode: gotMode, data_driven: !!dataDriven, v: SCRIPT_VERSION });
var didTrigger = false;
var observer = new IntersectionObserver(function (entries) {
if (didTrigger) return;
if (!entries[0].isIntersecting) return;
didTrigger = true;
observer.disconnect();
if (sentinel.parentNode) sentinel.parentNode.removeChild(sentinel);
onSentinelVisible(bucket, gotMode, dataDriven);
}, { root: null, rootMargin: '0px', threshold: 0 });
observer.observe(sentinel);
}
requestAnimationFrame(placeSentinel);
}
function main() {
var bucket = getPageBucket();
if (!bucket || bucket === 'default') return;
if (!isEligible(bucket)) return;
var pageCfg = pzReadPageGOTConfig();
var offerCfg = pzReadOfferGOTConfig();
if (!isEligibleOfferLayer(offerCfg)) return;
var gotMode;
var scrollPct;
var dataDriven = false;
if (pageCfg) {
dataDriven = true;
gotMode = pageCfg.mode;
scrollPct = pageCfg.scroll;
if (offerCfg && offerCfg.got_mode) {
if (offerCfg.got_mode === 'hard' && gotMode === 'soft') {
gotMode = 'hard';
dl({ event: 'pz_got_u_mode_override', from: 'soft', to: 'hard', offer_id: offerCfg.offer_id, v: SCRIPT_VERSION });
}
}
dl({ event: 'pz_got_u_config_loaded', bucket: bucket, got_mode: gotMode, got_scroll: pageCfg.scroll, data_driven: true, v: SCRIPT_VERSION });
} else {
if (!RATES[bucket]) return;
gotMode = 'soft';
scrollPct = null;
dl({ event: 'pz_got_u_config_loaded', bucket: bucket, got_mode: 'soft', data_driven: false, v: SCRIPT_VERSION });
}
setupScrollTrigger(bucket, scrollPct, gotMode, dataDriven);
}
// ENTRY POINT — v1.3.2: FIX-2 + GATE-1 + GATE-2
var didInit = false;
function startOnce(reason) {
if (didInit) {
dl({ event: 'pz_got_u_init_duplicate_blocked', reason: reason, v: SCRIPT_VERSION });
return;
}
didInit = true;
main();
}
(function waitForPZ(tries) {
if (w.__PZ && w.__PZ.pageType) { startOnce('pz_ready'); return; }
if (tries > 0) { setTimeout(function(){ waitForPZ(tries - 1); }, 200); return; }
dl({ event: 'pz_got_u_init_timeout', waited_ms: 4000, v: SCRIPT_VERSION });
})(20);
})(window, document);