From 863a3c6677fbfb96eefbe855529438d928f2ad96 Mon Sep 17 00:00:00 2001 From: rafa Date: Fri, 19 Jun 2026 11:49:59 -0400 Subject: [PATCH] feat(analytics): GA4 (gtag) + banner de consentimiento de cookies (#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fea-analytics.php: GA4 G-6RT9ZRS4LW vía gtag en mu-plugin (Consent Mode v2, default denied). Measurement ID portable: cutover wp-nuevo -> www indoloro. - fea-cookie-consent.php: banner RGPD discreto, multiidioma ES/EN/FR/IT/PT, enlace a la politica resuelto por idioma (Polylang). Aceptar -> consent update. Co-Authored-By: Claude Opus 4.8 --- .../wp-content/mu-plugins/fea-analytics.php | 40 +++++++ .../mu-plugins/fea-cookie-consent.php | 112 ++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 wordpress/wp-content/mu-plugins/fea-analytics.php create mode 100644 wordpress/wp-content/mu-plugins/fea-cookie-consent.php diff --git a/wordpress/wp-content/mu-plugins/fea-analytics.php b/wordpress/wp-content/mu-plugins/fea-analytics.php new file mode 100644 index 0000000..bc6d19e --- /dev/null +++ b/wordpress/wp-content/mu-plugins/fea-analytics.php @@ -0,0 +1,40 @@ + del front-end. + * Measurement ID portable: el cutover wp-nuevo.feadulta.com -> www.feadulta.com + * no requiere tocar nada (el ID no cambia; la Stream URL es informativa). + * NO se filtra tráfico interno (decisión Rafa: las IPs propias cuentan). + * Nota RGPD: GA4 setea cookies; si se añade banner de consentimiento habrá + * que condicionar este tag (Consent Mode) — pendiente, no implementado aquí. + */ +if (!defined('ABSPATH')) exit; + +define('FEA_GA4_MEASUREMENT_ID', 'G-6RT9ZRS4LW'); + +add_action('wp_head', function () { + // wp_head no corre en wp-admin; guard extra por seguridad. + if (is_admin()) return; + $gid = FEA_GA4_MEASUREMENT_ID; + ?> + + + + (ES/EN/FR/IT/PT). HTML idéntico para todos + * (cacheable); el estado por usuario se aplica en JS desde la cookie. + * Cambiar preferencias: window.feaOpenCookiePrefs() (engánchalo a un enlace del pie). + */ +if (!defined('ABSPATH')) exit; + +// Página de política de privacidad/cookies. ID del post madre (ES); el enlace +// se resuelve a la traducción del idioma actual vía Polylang. +define('FEA_PRIVACY_PAGE_ID', 21946); + +add_action('wp_footer', function () { + if (is_admin()) return; + // Resolver la política al idioma actual (Polylang); fallback al ID madre. + $priv_id = FEA_PRIVACY_PAGE_ID; + if (function_exists('pll_get_post') && function_exists('pll_current_language')) { + $tr = pll_get_post($priv_id, pll_current_language()); + if ($tr) $priv_id = $tr; + } + $privacy = get_permalink($priv_id); + $privacy = esc_url($privacy ? $privacy : '/'); + ?> + + + +