Add cross-domain tracking support (v1.2.0)

Add linker domains setting to Advanced tab for cross-domain measurement.
Outputs gtag('set','linker') before config call so GA4 appends the _gl
parameter to links pointing at configured domains.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 13:33:30 +00:00
parent 2294c8eda7
commit 868ed867e2
5 changed files with 41 additions and 5 deletions

View File

@@ -226,6 +226,18 @@ class ATT_Consent_Admin {
if ( $settings['wait_for_update'] > 10000 ) {
$settings['wait_for_update'] = 10000;
}
// Cross-domain tracking: sanitize each domain line.
$raw_domains = $_POST['cross_domain_domains'] ?? '';
$lines = array_filter( array_map( 'trim', explode( "\n", $raw_domains ) ) );
$clean = array();
foreach ( $lines as $line ) {
$domain = sanitize_text_field( $line );
if ( '' !== $domain ) {
$clean[] = $domain;
}
}
$settings['cross_domain_domains'] = implode( "\n", $clean );
break;
}