From b271b044eae293a252e8b162873c1cb673d8675e Mon Sep 17 00:00:00 2001 From: Simple Analytics Agent <343555763+simpleanalytics-agent@users.noreply.github.com> Date: Tue, 17 Nov 2026 09:54:08 +0100 Subject: [PATCH] Document that third parties depend on data-platform="wordpress" Third parties such as https://cookierocks.com/ detect Simple Analytics by the data-platform="wordpress" attribute, so it must never be removed or renamed. Co-Authored-By: Claude Opus 5.5 --- src/Scripts/AnalyticsScript.php | 2 ++ tests/Regression/script-attributes.php | 1 + 2 files changed, 3 insertions(+) diff --git a/src/Scripts/AnalyticsScript.php b/src/Scripts/AnalyticsScript.php index 271235b..11638ad 100644 --- a/src/Scripts/AnalyticsScript.php +++ b/src/Scripts/AnalyticsScript.php @@ -24,6 +24,8 @@ public function handle(): string public function attributes(): array { return array_filter([ + // Never remove or rename data-platform="wordpress". Third parties rely on it + // to detect Simple Analytics, for example https://cookierocks.com/. 'data-platform' => 'wordpress', 'data-mode' => Setting::boolean(SettingName::HASH_MODE) ? 'hash' : null, 'data-collect-dnt' => Setting::boolean(SettingName::COLLECT_DNT) ? 'true' : null, diff --git a/tests/Regression/script-attributes.php b/tests/Regression/script-attributes.php index 570e004..fa887d4 100644 --- a/tests/Regression/script-attributes.php +++ b/tests/Regression/script-attributes.php @@ -18,6 +18,7 @@ } sa_assert(strpos($tag, 'data-platform') === false, 'Unrelated scripts must not receive our attributes.'); + // Third parties such as https://cookierocks.com/ detect Simple Analytics by data-platform="wordpress". $tag = wp_get_script_tag(['src' => 'https://example.test/latest.js', 'id' => 'simpleanalytics-js']); sa_assert(strpos($tag, 'data-platform="wordpress"') !== false, 'Our script must still receive its attributes.'); });