Añadir mu-plugins y scripts de feadulta
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin Name: Fea Analytics — GA4 (#93)
|
||||
* Description: Inserta Google Analytics 4 (gtag.js) en el <head> 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;
|
||||
?>
|
||||
<!-- Google tag (gtag.js) - GA4 #93 -->
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
// Consent Mode v2: por defecto DENEGADO hasta que el usuario acepte en el
|
||||
// banner (fea-cookie-consent.php hace el consent 'update'). HTML idéntico
|
||||
// para todos (cacheable por Cloudflare); el estado por usuario lo aplica el
|
||||
// banner en JS leyendo la cookie.
|
||||
gtag('consent', 'default', {
|
||||
'ad_storage': 'denied',
|
||||
'ad_user_data': 'denied',
|
||||
'ad_personalization': 'denied',
|
||||
'analytics_storage': 'denied',
|
||||
'wait_for_update': 500
|
||||
});
|
||||
gtag('js', new Date());
|
||||
gtag('config', '<?php echo esc_js($gid); ?>');
|
||||
</script>
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_attr($gid); ?>"></script>
|
||||
<?php
|
||||
}, 1);
|
||||
Reference in New Issue
Block a user