From 868ed867e2e9e1145e186c56f3e28f7b5b3f56bd Mon Sep 17 00:00:00 2001
From: Steve Hanlon
Date: Wed, 4 Mar 2026 13:33:30 +0000
Subject: [PATCH] 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
---
admin/views/settings-advanced.php | 14 ++++++++++++++
att-consent.php | 4 ++--
includes/class-admin.php | 12 ++++++++++++
includes/class-att-consent.php | 7 ++++---
includes/class-frontend.php | 9 +++++++++
5 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/admin/views/settings-advanced.php b/admin/views/settings-advanced.php
index 1ced04f..fca1e4d 100644
--- a/admin/views/settings-advanced.php
+++ b/admin/views/settings-advanced.php
@@ -55,6 +55,20 @@ if ( ! defined( 'ABSPATH' ) ) {
+
+ |
+
+ |
+
+
+
+
+
+
+
+
+ |
+
diff --git a/att-consent.php b/att-consent.php
index 815e7db..311a616 100644
--- a/att-consent.php
+++ b/att-consent.php
@@ -3,7 +3,7 @@
* Plugin Name: ATT Consent
* Plugin URI: https://github.com/att-consent/att-consent
* Description: Google Consent Mode v2 cookie consent with session attribution preservation, custom script management, and full gtag.js/GTM support.
- * Version: 1.1.0
+ * Version: 1.2.0
* Requires at least: 6.0
* Requires PHP: 7.4
* Author: ATT Consent
@@ -18,7 +18,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
-define( 'ATT_CC_VERSION', '1.1.0' );
+define( 'ATT_CC_VERSION', '1.2.0' );
define( 'ATT_CC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'ATT_CC_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'ATT_CC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
diff --git a/includes/class-admin.php b/includes/class-admin.php
index 214e2a8..7cfa284 100644
--- a/includes/class-admin.php
+++ b/includes/class-admin.php
@@ -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;
}
diff --git a/includes/class-att-consent.php b/includes/class-att-consent.php
index f3b9f14..d1ad50b 100644
--- a/includes/class-att-consent.php
+++ b/includes/class-att-consent.php
@@ -60,9 +60,10 @@ class ATT_Consent {
'cat_marketing_desc' => 'These cookies are used to deliver advertisements relevant to you.',
// Advanced.
- 'url_passthrough' => true,
- 'ads_data_redaction' => true,
- 'wait_for_update' => 500,
+ 'url_passthrough' => true,
+ 'ads_data_redaction' => true,
+ 'wait_for_update' => 500,
+ 'cross_domain_domains' => '',
);
/**
diff --git a/includes/class-frontend.php b/includes/class-frontend.php
index 8ca42ab..eeb0a4b 100644
--- a/includes/class-frontend.php
+++ b/includes/class-frontend.php
@@ -57,6 +57,14 @@ class ATT_Consent_Frontend {
'tracking_mode' => $s['tracking_mode'],
);
+ // Cross-domain tracking domains.
+ if ( ! empty( $s['cross_domain_domains'] ) ) {
+ $domains = array_filter( array_map( 'trim', explode( "\n", $s['cross_domain_domains'] ) ) );
+ if ( ! empty( $domains ) ) {
+ $config['linker_domains'] = array_values( $domains );
+ }
+ }
+
// In basic mode, pass the tracking snippet for deferred injection.
if ( 'basic' === $s['consent_mode'] ) {
$config['tracking_snippet'] = $this->get_tracking_snippet();
@@ -107,6 +115,7 @@ wait_for_update:c.wait_for_update||500
});
window.attCCHasConsent=false;
}
+if(c.linker_domains&&c.linker_domains.length){g('set','linker',{'domains':c.linker_domains});}
if(!sessionStorage.getItem('att_cc_attr')){
var p=new URLSearchParams(window.location.search);
var a={