Skip to content

Commit

Permalink
Add analytics for donation form submit
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi committed Nov 27, 2024
1 parent 817f2ce commit ad553c7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions site/DonateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ 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]

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"
Expand Down Expand Up @@ -163,6 +166,8 @@ export class DonateForm extends React.Component {
)
}

analytics.logSiteFormSubmit("donate")

window.location.href = session.url
}

Expand Down Expand Up @@ -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
<FontAwesomeIcon
Expand Down

0 comments on commit ad553c7

Please sign in to comment.