From e56ee781ea6deac0336cf7e7287c51a9e905b5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ra=C4=8D=C3=A1k?= Date: Wed, 27 Nov 2024 13:12:16 +0100 Subject: [PATCH] Add analytics for donation form submit --- site/DonateForm.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/site/DonateForm.tsx b/site/DonateForm.tsx index 6028d4908ce..d6e910660fe 100644 --- a/site/DonateForm.tsx +++ b/site/DonateForm.tsx @@ -27,6 +27,7 @@ import { Checkbox } from "@ourworldindata/components" import { FontAwesomeIcon } from "@fortawesome/react-fontawesome/index.js" import { faArrowRight, faInfoCircle } from "@fortawesome/free-solid-svg-icons" import Bugsnag from "@bugsnag/js" +import { SiteAnalytics } from "./SiteAnalytics.js" const ONETIME_DONATION_AMOUNTS = [20, 50, 100, 500, 1000] const MONTHLY_DONATION_AMOUNTS = [5, 10, 25, 50, 100] @@ -34,6 +35,8 @@ const MONTHLY_DONATION_AMOUNTS = [5, 10, 25, 50, 100] const ONETIME_DEFAULT_INDEX = 2 const MONTHLY_DEFAULT_INDEX = 2 +const analytics = new SiteAnalytics() + @observer export class DonateForm extends React.Component { @observable interval: DonationInterval = "once" @@ -163,6 +166,8 @@ export class DonateForm extends React.Component { ) } + analytics.logSiteFormSubmit("donate") + window.location.href = session.url } @@ -356,6 +361,7 @@ export class DonateForm extends React.Component { type="submit" className="donation-submit" disabled={this.isLoading || this.isSubmitting} + onClick={() => analytics.logSiteClick("donate-now")} > Donate now