| Server IP : 35.80.110.71 / Your IP : 216.73.216.221 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wp/shared/platform/mu-plugins/ |
Upload File : |
<?php
/**
* Plugin Name: SFP — Analytics (GA4)
* Description: Injects the shared Google Analytics 4 gtag.js snippet on every front-end page. Symlinked into each demo via the platform mu-plugins fan-out. Skips admin, customizer preview, and any host that is not under philiprehberger.com.
* Version: 1.0.0
* Author: ScopeForged
* Network: true
*/
if (!defined('ABSPATH')) {
exit;
}
/**
* Shared GA4 measurement ID. One property covers every philiprehberger.com
* subdomain (Next.js demos + WP tenants). GA4 treats them as a single site —
* split per-tenant in reports via the built-in "Page hostname" dimension.
*/
const SFP_GA4_MEASUREMENT_ID = 'G-HZ8Z4XP611';
add_action('wp_head', function () {
if (is_admin() || is_customize_preview()) {
return;
}
// Defensive guard: this plugin is symlinked into every demo on the platform.
// Only emit gtag for hosts under philiprehberger.com so we don't pollute the
// GA property with traffic from other brands (e.g. scopeforged-library-wp).
$host = isset($_SERVER['HTTP_HOST']) ? strtolower($_SERVER['HTTP_HOST']) : '';
if ($host !== 'philiprehberger.com' && !str_ends_with($host, '.philiprehberger.com')) {
return;
}
$id = SFP_GA4_MEASUREMENT_ID;
if (empty($id) || $id === 'G-XXXXXXXXXX') {
return;
}
?>
<!-- Google Analytics 4 (sfp-analytics) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=<?php echo esc_attr($id); ?>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '<?php echo esc_js($id); ?>');
</script>
<?php
}, 1);