diff --git a/odoo-black-friday/index.html b/odoo-black-friday/index.html
index b36feb6..f96dfc6 100644
--- a/odoo-black-friday/index.html
+++ b/odoo-black-friday/index.html
@@ -1070,6 +1070,8 @@
class="ads-consent"
role="region"
aria-label="Advertising cookie consent"
+ data-ads-id="AW-18065522009"
+ data-ads-send-to="AW-18065522009/vnDUCPDxt7AdENn6p6ZD"
hidden
>
diff --git a/static/ads-consent.js b/static/ads-consent.js
index a9b535c..0c97324 100644
--- a/static/ads-consent.js
+++ b/static/ads-consent.js
@@ -1,6 +1,9 @@
/* ads-consent.js — Google Ads tag, gated behind a consent banner. Page-side only.
*
* Page: /odoo-black-friday/. Companion to /static/black-friday.js (which is untouched).
+ * The tag ID and the conversion label are read from the banner element's data-* attributes
+ * (#adsConsent[data-ads-id][data-ads-send-to]), so this file stays generic and reusable and
+ * the page holds the one copy of the config. Without those attributes the script stays inert.
*
* WHY A GATE: the Google Ads tag is NOT cookieless — it sets the advertising cookies
* _gcl_au / _gcl_aw. So nothing loads and no request fires until the visitor accepts.
@@ -17,10 +20,9 @@
(function () {
"use strict";
- var AW_ID = "AW-18065522009";
- var SEND_TO = "AW-18065522009/vnDUCPDxt7AdENn6p6ZD";
var STORE_KEY = "o4p_ads_consent"; // "granted" | "denied"
var SUBMIT_FALLBACK_MS = 700; // hard cap: submit even if the tag never answers
+ var cfg = null; // { id, sendTo } — read from the banner, never hard-coded
/* ---- the visitor's stored choice ---- */
function readChoice() {
@@ -61,7 +63,7 @@
/* ---- the tag: loaded ONLY on consent ---- */
function loadGtag() {
- if (window.__o4pAdsLoaded) return;
+ if (!cfg || window.__o4pAdsLoaded) return;
window.__o4pAdsLoaded = true;
window.dataLayer = window.dataLayer || [];
window.gtag =
@@ -70,10 +72,10 @@
window.dataLayer.push(arguments);
};
window.gtag("js", new Date());
- window.gtag("config", AW_ID);
+ window.gtag("config", cfg.id);
var s = document.createElement("script");
s.async = true;
- s.src = "https://www.googletagmanager.com/gtag/js?id=" + AW_ID;
+ s.src = "https://www.googletagmanager.com/gtag/js?id=" + cfg.id;
document.head.appendChild(s);
}
@@ -84,8 +86,8 @@
var action = form.getAttribute("action") || "";
if (action.indexOf("/shop/post_basket") === -1) return;
- // No consent, or no tag: do nothing, let the native POST go through untouched.
- if (!isGranted() || typeof window.gtag !== "function") return;
+ // Not configured, no consent, or no tag: do nothing, let the native POST go through.
+ if (!cfg || !isGranted() || typeof window.gtag !== "function") return;
e.preventDefault();
var submitted = false;
@@ -96,7 +98,7 @@
}
try {
window.gtag("event", "conversion", {
- send_to: SEND_TO,
+ send_to: cfg.sendTo,
event_callback: submitNow,
});
} catch (err) {
@@ -135,6 +137,12 @@
var banner = bannerEl();
if (!banner) return;
+ // Config lives in the page. Missing config -> stay inert (no tag, no conversion).
+ var id = banner.getAttribute("data-ads-id");
+ var sendTo = banner.getAttribute("data-ads-send-to");
+ if (!id || !sendTo) return;
+ cfg = { id: id, sendTo: sendTo };
+
var choice = readChoice();
if (choice === "granted") {
loadGtag(); // returning visitor who already accepted: load straight away