Add data-ph- elements to CTA buttons #1821
Merged
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?
https://github.com/mitodl/hq/issues/5989
Description (What does it do?)
We need a clear way to identify when users click on the CTA button in the Learning Resource drawer - this adds that, in the form of
data-ph-
attributes.The attributes that are added are:
data-ph-action
- set toclick-cta
(this is the standard PostHog attribute we decided on)data-ph-offered-by
- set to the offeror codedata-ph-resource-type
- set to the resource typedata-ph-resource-id
- set to the resource IDThese are added to both the V1 and V2 LearningResourceExpanded components since the v2 one isn't rolled out yet.
How can this be tested?
This does not handle video resources - videos will require more work (due to the CTA being the embedded video itself). So, choose resources that aren't videos. These will be handled in a future PR.
The easiest way to test this is to create an Action in PostHog's Data Management tab. Set up an Action that has one Match Group. The Match Group should be set to Autocapture and the "Element matches HTML selector" should be set to
[data-ph-action="click-cta"]
.Then, load some resources and click the CTA buttons in the drawers. You should see events match in the Action after some delay.