Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions ANALYTICS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,32 @@ Analytics loads only for Netlify production builds.
| `installation_copy` | A successful code-block copy containing a Suites install command | Intent to install Suites |
| `test_example_copy` | A successful code-block copy containing a `TestBed.solitary()` or `TestBed.sociable()` example on a framework guide | Intent to try a framework example |
| `search_result_click` | Selecting a search result | Search helped the reader find a document |
| `quickstart_click` | Selecting a homepage Quick Start link | Intent to start the first-test guide; `cta_location` identifies the header, mobile menu, hero, features, or footer |

Copy events send the page path and, for framework examples, the framework name. They never send copied code. They observe Expressive Code's successful clipboard feedback, so a failed copy does not count. Copies do not prove an installation or a passing test.

Search opens, search results, and empty searches remain diagnostic events. The existing `ads_conversion_PAGE_VIEW_1` measures page-view conversions and must not be interpreted as adoption.
Search opens, search results, empty searches, and Quick Start clicks remain diagnostic events. The existing `ads_conversion_PAGE_VIEW_1` measures page views and must not be interpreted as adoption.

## GA property setup

After reviewing and deploying the branch:
Property settings updated on **19 November 2026**:

1. In **Admin > Data display > Events**, create or mark `installation_copy` and `test_example_copy` as key events. Use **Once per session** for each. GA allows registering event names before their first occurrence.
2. Under **Custom definitions**, create an event-scoped dimension named **Framework**, with event parameter `framework`.
3. Keep `search_result_click` available for search reporting. Do not treat search activity alone as installation intent.
1. Removed the key-event flag from `ads_conversion_PAGE_VIEW_1`. The event remains available as an ordinary event. GA warned that unmarking also stops future conversion association in linked accounts, including Google Ads. Historical data remains unchanged.
2. Registered `installation_copy` and `test_example_copy` as code-based key events, counted **Once per session**, with no default monetary value. No page-view-derived event rules were created.
3. Registered event-scoped dimensions: **Framework** for `framework`, **CTA location** for `cta_location`, and **Search term** for `search_term`.
4. Keep `search_result_click` and `quickstart_click` available for diagnostic reporting rather than marking them as adoption key events.
5. Added a 19 November annotation in GA documenting the conversion and engagement baseline change.

Property setup is separate from the website code. Check the GA interface for the registered definitions before treating setup as complete. Key-event registration applies to future events, not historical data.
Property setup is separate from the website code. The Quick Start click event and CTA changes require this branch to be deployed. Key-event registration and custom dimensions apply to future data, not historical data. The built-in `purchase` key event remains unchanged.

GA counts a session as engaged when it has a key event. Before this correction, every docs page view generated `ads_conversion_PAGE_VIEW_1`, so engagement and conversion rates overstated meaningful activity. Compare engagement against the new baseline from 19 November, rather than interpreting a subsequent fall as a website regression.

## Validate without polluting production data

In a local build with `CONTEXT=production`, block Google tag network requests and stub `window.gtag` to capture calls. Copy a Suites install command and a framework test example. Each successful copy should emit the corresponding event; unrelated code and failed copies should emit neither event. A normal preview build must load no Google tag.

`pnpm test` includes DOM integration tests that execute the installed Expressive Code copy-button script together with the adoption observer. They cover successful install and test-example copies, repeated successful copies, clipboard failure, unrelated snippets, and unrelated feedback. Test events stay in memory and never reach GA.

Run `pnpm test`, `pnpm check`, and `CONTEXT=production pnpm build` for automated checks.

## Compare launch performance
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
},
"devDependencies": {
"@types/react": "^18.3.0",
"@types/react-dom": "^18.3.0"
"@types/react-dom": "^18.3.0",
"linkedom": "^0.18.15"
},
"engines": {
"node": ">=22",
Expand Down
119 changes: 119 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 2 additions & 15 deletions src/components/islands/AdoptionAnalytics.astro
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
<script>
import { copiedCodeEvent } from '@/lib/adoptionAnalytics.js';
import { observeCodeCopies } from '@/lib/adoptionAnalytics.js';
import { trackEvent } from '@/utils/analytics';

// Expressive Code adds this feedback only after a successful clipboard copy.
// Observing feedback avoids counting failed clipboard attempts as adoption.
const observer = new MutationObserver(records => {
for (const record of records) {
for (const node of record.addedNodes) {
if (!(node instanceof HTMLElement) || !node.matches('.feedback')) continue;
const button = node.parentElement?.matches('.expressive-code .copy')
? node.parentElement.querySelector<HTMLButtonElement>('button[data-code]')
: null;
if (!button) continue;
const event = copiedCodeEvent(window.location.pathname, button.dataset.code ?? '');
if (event) trackEvent(event.name, event.params);
}
}
});
observer.observe(document.body, { childList: true, subtree: true });
observeCodeCopies(document, () => window.location.pathname, trackEvent);
</script>
6 changes: 5 additions & 1 deletion src/components/site/MarketingHeader.astro
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Topbar from '@/components/ui/Topbar.astro';
import ThemeToggle from '@/components/site/ThemeToggle.astro';

const marketingNavLinks = [
{ label: 'Documentation', href: '/docs/get-started/' },
{ label: 'Documentation', href: '/docs/' },
{ label: 'Quick start', href: '/docs/get-started/quickstart/' },
{
label: 'Examples',
Expand Down Expand Up @@ -44,6 +44,8 @@ const marketingMobileResources = [
<a
class="marketing-nav-link"
href={link.href}
data-track={link.label === 'Quick start' ? 'quick_start' : undefined}
data-track-location={link.label === 'Quick start' ? 'homepage_header' : undefined}
{...(link.external ? { target: '_blank', rel: 'noopener noreferrer' } : {})}
>
<span>{link.label}</span>
Expand Down Expand Up @@ -81,6 +83,8 @@ const marketingMobileResources = [
<a
class="marketing-mobile-link"
href={link.href}
data-track={link.label === 'Quick start' ? 'quick_start' : undefined}
data-track-location={link.label === 'Quick start' ? 'homepage_mobile_menu' : undefined}
>
<span>{link.label}</span>
<small>
Expand Down
Loading
Loading