Add posthog enrollment_cta_clicked event with enrollment-specific data#3542
Merged
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
ce9d858 to
fb428ce
Compare
5ec1486 to
47af1af
Compare
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>
47af1af to
b879559
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What are the relevant tickets?
Description (What does it do?)
This changes the posthog event tracking on product pages:
cta_clickedevent with course-identifying data and label. (Brittle... charts break whenever we change label)enroll_cta_clickedevent 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.
enrollment_modeshould come through correctly