Skip to content

Add posthog enrollment_cta_clicked event with enrollment-specific data#3542

Merged
ChristopherChudzicki merged 3 commits into
mainfrom
cc/hq-11941-enroll-cta-event
Jul 2, 2026
Merged

Add posthog enrollment_cta_clicked event with enrollment-specific data#3542
ChristopherChudzicki merged 3 commits into
mainfrom
cc/hq-11941-enroll-cta-event

Conversation

@ChristopherChudzicki

@ChristopherChudzicki ChristopherChudzicki commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What are the relevant tickets?

Description (What does it do?)

This changes the posthog event tracking on product pages:

  • BEFORE: Single cta_clicked event with course-identifying data and label. (Brittle... charts break whenever we change label)
  • AFTER: Enrollment-specific enroll_cta_clicked event with enrollment-specific data, e.g., enrollment_mode.

How can this be tested?

Prerequisites: Personal posthog integrated with your local, plus MIT Learn and MITxOnline integrated with courses set up; at least a course with both free and paid enrollment modes.

  1. View a product page with both free and paid enrollment modes. if it has both audit and verified modes, you will see it has 2 enrollment buttons in the infobox, and a third in the header.
  2. In infobox, click "Enroll". You should be redirected to MITxOnline.
    • Check posthog; you should see an event come through with relevant data and it should correctly reflect enrollment_mode ("verified")
    • NB: This can take a minute or two to finish ingestion in posthog, and you can continue with the other steps
  3. Try the header button, too. It should match the primary-styled (filled red) infobox button, so verified if both verified and audit modes are available.
  4. In infobox, click "Learn for Free", you should be redirected to Dashboard.
    • Check posthog; you should see an event come through with relevant data and it should correctly reflect enrollment_mode ("audit")
  5. If you try other courses (e.g., free-only or paid-only) the enrollment_mode should come through correctly

@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown

OpenAPI Changes

No changes detected

View full changelog

Unexpected changes? Ensure your branch is up-to-date with main (consider rebasing).

@ChristopherChudzicki ChristopherChudzicki changed the title Cc/hq 11941 enroll cta event Add posthog enrollment_cta_clicked event with enrollment-specific data Jun 30, 2026
@ChristopherChudzicki ChristopherChudzicki marked this pull request as ready for review June 30, 2026 21:23
@ChristopherChudzicki ChristopherChudzicki added the Needs Review An open Pull Request that is ready for review label Jul 1, 2026

@daniellefrappier18 daniellefrappier18 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Image Image Image

@ChristopherChudzicki ChristopherChudzicki force-pushed the cc/hq-11787-course-infobox branch from ce9d858 to fb428ce Compare July 1, 2026 20:27
@ChristopherChudzicki ChristopherChudzicki force-pushed the cc/hq-11941-enroll-cta-event branch from 5ec1486 to 47af1af Compare July 1, 2026 20:27
Base automatically changed from cc/hq-11787-course-infobox to main July 1, 2026 23:54
ChristopherChudzicki and others added 3 commits July 1, 2026 19:57
Course enroll CTAs fired the generic `cta_clicked` event keyed on the visible
button copy, so analytics insights broke whenever labels changed (hq#11941) —
and the infobox redesign changes them again.

Emit a dedicated `enroll_cta_clicked` event from the course enroll handlers
(header + infobox) with structured, copy-independent properties:
  - placement: "header" | "infobox"
  - enrollment_mode: "verified" | "audit"
  - resource_type, readable_id (+ label retained for humans, not as the key)

Placement is threaded via a new useCourseEnrollment opt set by each call site.
Generic cta_clicked is unchanged elsewhere.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Review follow-ups on the dedicated enroll_cta_clicked event:
- Make `placement` required in the useCourseEnrollment opts so a future call
  site can't silently emit `placement: undefined` (the same silent-drop class
  hq#11941 fixes). Both existing call sites already pass it.
- Add `platform: PlatformEnum.Mitxonline` for parity with sibling cta events
  (constant on these product pages; was not on the old course-enroll event).
- Use camelCase property keys (enrollmentMode/resourceType/readableId) to match
  the repo's established convention across all ~15 capture sites, so `readableId`
  lines up with the legacy cta_clicked for a clean cross-event breakdown.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`useCourseEnrollment`'s opts mixed analytics metadata (`placement`, used only
for the enroll_cta_clicked event) with behavior (`onRequireSignup`). Group the
analytics-only field under a `tracking` key so the two intents are structurally
separated:

  useCourseEnrollment(course, run, {
    tracking: { placement: "infobox" },   // analytics-only
    onRequireSignup,                       // behavioral
  })

No behavior change. Checked the sibling handlers — ProgramEnrollmentButton and
the other capture sites fire inline without a mixed opts object, so none need an
analogous change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ChristopherChudzicki ChristopherChudzicki force-pushed the cc/hq-11941-enroll-cta-event branch from 47af1af to b879559 Compare July 2, 2026 00:01
@ChristopherChudzicki ChristopherChudzicki merged commit 7375d41 into main Jul 2, 2026
13 checks passed
@ChristopherChudzicki ChristopherChudzicki deleted the cc/hq-11941-enroll-cta-event branch July 2, 2026 11:15
@odlbot odlbot mentioned this pull request Jul 2, 2026
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review An open Pull Request that is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants