diff --git a/README.md b/README.md index 2b160bf6..e2fe741c 100644 --- a/README.md +++ b/README.md @@ -147,3 +147,27 @@ the JSON file and hosting/VPS release logs before changing redirects or DNS. An HTTP failure reported in this tool is an observation from the machine running it, not definitive proof the origin is offline to every user. This script makes no publishing, cache-purge, tracking or DNS changes. + + +## Press-to-store GA4 event unification (2026-11-13) + +All five press locales retain the original `press_app_click` event for both +app detail links and Play outbound links. A *real Play click* now additionally +fires the website-wide `download_click` event with allowlisted event data: +store=google_play, location=press, placement=press_kit_card, source=press_kit, +app_slug, app_package, locale. A detail-page click does **not** emit +`download_click`. These represent outbound links **not installs**. No +raw search terms, URLs, private user data or unique identifiers are sent. + +Run source tests: + +```bash +node --test scripts/test_press_store_events.cjs +python3 -m unittest scripts.test_press_kit -v +``` + +Following an authorized VPS publish, the existing live smoke now requires +unified press click source on each of the five routes. Use GA4 DebugView to +verify one `press_app_click` per real press link click and one +`download_click` per *Play* click, without counting app detail clicks +as installs. Store acquired users must be verified separately in Play Console. diff --git a/press/es/index.html b/press/es/index.html index 64de2638..004e5910 100644 --- a/press/es/index.html +++ b/press/es/index.html @@ -45,6 +45,18 @@ locale:document.documentElement.lang, placement:'press_kit' }); + // Match the site's shared outbound-store event without counting detail clicks as downloads. + if(a.getAttribute('data-cta')==='store'){ + gtag('event','download_click',{ + store:'google_play', + location:'press', + placement:'press_kit_card', + app_slug:a.getAttribute('data-app-slug')||'', + app_package:a.getAttribute('data-app-package')||'', + locale:document.documentElement.lang, + source:'press_kit' + }); + } },true); diff --git a/press/id/index.html b/press/id/index.html index 5136def0..ea9b9ca3 100644 --- a/press/id/index.html +++ b/press/id/index.html @@ -45,6 +45,18 @@ locale:document.documentElement.lang, placement:'press_kit' }); + // Match the site's shared outbound-store event without counting detail clicks as downloads. + if(a.getAttribute('data-cta')==='store'){ + gtag('event','download_click',{ + store:'google_play', + location:'press', + placement:'press_kit_card', + app_slug:a.getAttribute('data-app-slug')||'', + app_package:a.getAttribute('data-app-package')||'', + locale:document.documentElement.lang, + source:'press_kit' + }); + } },true); diff --git a/press/index.html b/press/index.html index 726afb61..1953df60 100644 --- a/press/index.html +++ b/press/index.html @@ -45,6 +45,18 @@ locale:document.documentElement.lang, placement:'press_kit' }); + // Match the site's shared outbound-store event without counting detail clicks as downloads. + if(a.getAttribute('data-cta')==='store'){ + gtag('event','download_click',{ + store:'google_play', + location:'press', + placement:'press_kit_card', + app_slug:a.getAttribute('data-app-slug')||'', + app_package:a.getAttribute('data-app-package')||'', + locale:document.documentElement.lang, + source:'press_kit' + }); + } },true); diff --git a/press/ja/index.html b/press/ja/index.html index 60668644..0ffcdaf4 100644 --- a/press/ja/index.html +++ b/press/ja/index.html @@ -45,6 +45,18 @@ locale:document.documentElement.lang, placement:'press_kit' }); + // Match the site's shared outbound-store event without counting detail clicks as downloads. + if(a.getAttribute('data-cta')==='store'){ + gtag('event','download_click',{ + store:'google_play', + location:'press', + placement:'press_kit_card', + app_slug:a.getAttribute('data-app-slug')||'', + app_package:a.getAttribute('data-app-package')||'', + locale:document.documentElement.lang, + source:'press_kit' + }); + } },true); diff --git a/press/pt-br/index.html b/press/pt-br/index.html index 3e4ec559..4c01f4c3 100644 --- a/press/pt-br/index.html +++ b/press/pt-br/index.html @@ -45,6 +45,18 @@ locale:document.documentElement.lang, placement:'press_kit' }); + // Match the site's shared outbound-store event without counting detail clicks as downloads. + if(a.getAttribute('data-cta')==='store'){ + gtag('event','download_click',{ + store:'google_play', + location:'press', + placement:'press_kit_card', + app_slug:a.getAttribute('data-app-slug')||'', + app_package:a.getAttribute('data-app-package')||'', + locale:document.documentElement.lang, + source:'press_kit' + }); + } },true); diff --git a/scripts/check_app_discovery_live.sh b/scripts/check_app_discovery_live.sh index a77550dd..b04ce007 100644 --- a/scripts/check_app_discovery_live.sh +++ b/scripts/check_app_discovery_live.sh @@ -90,6 +90,7 @@ for entry in 'en:press/:en' 'es:press/es/:es' 'pt-br:press/pt-br/:pt-BR' 'ja:pre grep -Fq "" "$tmp/press-$code.html" || { echo "FAIL press $code language not live" >&2; exit 1; } grep -Fq "https://appdevelopsk.com/$route" "$tmp/press-$code.html" || { echo "FAIL press $code canonical not live" >&2; exit 1; } grep -Fq 'press_app_click' "$tmp/press-$code.html" || { echo "FAIL press $code app attribution missing" >&2; exit 1; } + grep -Fq "'download_click'" "$tmp/press-$code.html" || { echo "FAIL press $code unified store click attribution missing" >&2; exit 1; } done fetch '/support/face-reaction-battle/' 'face-battle.html' grep -Fq 'data-alternative="instant-judge"' "$tmp/face-battle.html" || { echo 'FAIL unavailable game alternative CTA missing' >&2; exit 1; } diff --git a/scripts/test_press_kit.py b/scripts/test_press_kit.py index f4adc805..0c2afc26 100644 --- a/scripts/test_press_kit.py +++ b/scripts/test_press_kit.py @@ -57,6 +57,8 @@ def test_all_locales_and_store_destinations(self): self.assertIn("/apps", anchors) self.assertNotIn("utm_source=presskit", html, "Internal UTMs would reset acquisition attribution") self.assertIn("press_app_click", html) + self.assertIn("'download_click'", html) + self.assertIn("source:'press_kit'", html) self.assertEqual(sum(x.get("data-cta")=="store" for tag,x in doc.attrs if tag=="a"), 5) self.assertEqual(sum(tag=="a" and attrs.get("lang") in PAGES for tag,attrs in doc.attrs), len(PAGES)) diff --git a/scripts/test_press_store_events.cjs b/scripts/test_press_store_events.cjs new file mode 100644 index 00000000..0be7fa37 --- /dev/null +++ b/scripts/test_press_store_events.cjs @@ -0,0 +1,73 @@ +'use strict'; +// Offline browser-style contract for five localized press/creator pages. +// Run: node --test scripts/test_press_store_events.cjs +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); +const vm = require('node:vm'); + +const PAGES = { + en: 'press/index.html', + es: 'press/es/index.html', + 'pt-BR': 'press/pt-br/index.html', + ja: 'press/ja/index.html', + id: 'press/id/index.html', +}; + +function exercise(locale, cta) { + const html = fs.readFileSync(path.join(__dirname, '..', PAGES[locale]), 'utf8'); + const scripts = [...html.matchAll(/]*)>([\s\S]*?)<\/script>/g)].map(m => m[1]); + const handlers = scripts.filter(s => s.includes("'press_app_click'")); + assert.equal(handlers.length, 1, 'one press click handler per locale'); + let onClick = null; + const document = { + documentElement: { lang: locale }, + addEventListener(event, callback, capture) { + assert.equal(event, 'click'); + assert.equal(capture, true); + onClick = callback; + }, + }; + const context = { document, Date }; + context.window = context; + vm.runInNewContext(handlers[0], context); + assert.equal(typeof onClick, 'function'); + const values = { + 'data-app-slug': 'blur', + 'data-app-package': 'com.blurapp.blur_app', + 'data-cta': cta, + }; + const anchor = { getAttribute: key => values[key] ?? null }; + onClick({ target: { closest: selector => { + assert.equal(selector, 'a[data-cta]'); + return anchor; + } } }); + return context.dataLayer + .filter(row => row[0] === 'event') + .map(row => ({ name: row[1], payload: JSON.parse(JSON.stringify(row[2])) })); +} + +for (const locale of Object.keys(PAGES)) { + test(locale + ': store click yields press event plus one unified outbound event', () => { + const events = exercise(locale, 'store'); + assert.deepEqual(events.map(x => x.name), ['press_app_click', 'download_click']); + assert.equal(events[0].payload.destination, 'store'); + assert.equal(events[0].payload.locale, locale); + assert.equal(events[1].payload.store, 'google_play'); + assert.equal(events[1].payload.location, 'press'); + assert.equal(events[1].payload.placement, 'press_kit_card'); + assert.equal(events[1].payload.source, 'press_kit'); + assert.equal(events[1].payload.locale, locale); + assert.equal(events[1].payload.app_slug, 'blur'); + assert.equal(events[1].payload.app_package, 'com.blurapp.blur_app'); + assert.equal(JSON.stringify(events).includes('link_url'), false); + assert.equal(JSON.stringify(events).includes('query'), false); + }); + + test(locale + ': app detail click never fires a Play store event', () => { + const events = exercise(locale, 'details'); + assert.deepEqual(events.map(x => x.name), ['press_app_click']); + assert.equal(events[0].payload.destination, 'details'); + }); +}