Skip to content

Commit 37efb5b

Browse files
Per-button partner_metadata: track which donate button was clicked
Renamed fields: landing (entry page), source (exit page), button (header, intro-bottom, big-cta, footer, content). Removed locale. Added data-track to footer and FAQ donate links. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 2c71b21 commit 37efb5b

2 files changed

Lines changed: 15 additions & 14 deletions

File tree

src/layouts/Layout.astro

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ import { OpenPanelComponent } from '@openpanel/astro';
253253
<ul>
254254
<li><a href="/funding">Funding</a></li>
255255
<li><a href="/faq">FAQ</a></li>
256-
<li><a href={EVERYORG_BUTTON_URL}>Donate</a></li>
256+
<li><a href={EVERYORG_BUTTON_URL} data-track="footer-donate">Donate</a></li>
257257
</ul>
258258
</nav>
259259
<div class="footer-legal">
@@ -331,22 +331,23 @@ import { OpenPanelComponent } from '@openpanel/astro';
331331
// Inject tracking params into donate hrefs BEFORE the Every.org widget loads
332332
// — the widget reads params from href at init time
333333
const urlParams = new URLSearchParams(window.location.search);
334-
const metadata = {
335-
visitor_id: window.__oseVisitorId,
336-
source_page: window.location.pathname,
337-
entry_page: sessionStorage.getItem('ose_entry') || window.location.pathname,
338-
datetime: new Date().toISOString(),
339-
locale: navigator.language,
340-
utm_source: urlParams.get('utm_source') || undefined,
341-
utm_medium: urlParams.get('utm_medium') || undefined,
342-
utm_campaign: urlParams.get('utm_campaign') || undefined,
343-
utm_content: urlParams.get('utm_content') || undefined,
344-
};
345-
const metadataB64 = btoa(JSON.stringify(metadata));
334+
const buttonMap = { 'header-donate': 'header', 'intro-bottom-donate': 'intro-bottom', 'big-cta-donate': 'big-cta', 'footer-donate': 'footer', 'content-donate': 'content' };
346335

347336
document.querySelectorAll('a[href*="every.org/osendowment"]').forEach((link) => {
348337
const href = link.getAttribute('href');
349338
if (href.includes('partner_metadata')) return;
339+
const metadata = {
340+
visitor_id: window.__oseVisitorId,
341+
landing: sessionStorage.getItem('ose_entry') || window.location.pathname,
342+
source: window.location.pathname,
343+
button: buttonMap[link.dataset.track] || 'other',
344+
datetime: new Date().toISOString(),
345+
utm_source: urlParams.get('utm_source') || undefined,
346+
utm_medium: urlParams.get('utm_medium') || undefined,
347+
utm_campaign: urlParams.get('utm_campaign') || undefined,
348+
utm_content: urlParams.get('utm_content') || undefined,
349+
};
350+
const metadataB64 = btoa(JSON.stringify(metadata));
350351
const [base, hash] = href.split('#');
351352
link.setAttribute('href',
352353
base + '&partner_metadata=' + encodeURIComponent(metadataB64)

src/pages/faq.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ const orgDonorCount = stats.donors.organizations;
290290
<div class="faq-item">
291291
<h3>How do I donate?</h3>
292292
<div class="faq-answer">
293-
<p>People and organizations are welcome to <a href={EVERYORG_BUTTON_URL}>donate here</a>. We accept card payments, Apple/Google Pay, US and international bank transfers, donor-advised funds (DAF), crypto, public and private stock — all non-USD assets are automatically converted.</p>
293+
<p>People and organizations are welcome to <a href={EVERYORG_BUTTON_URL} data-track="content-donate">donate here</a>. We accept card payments, Apple/Google Pay, US and international bank transfers, donor-advised funds (DAF), crypto, public and private stock — all non-USD assets are automatically converted.</p>
294294
</div>
295295
</div>
296296

0 commit comments

Comments
 (0)