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 to click-cta (this is the standard PostHog attribute we decided on)
data-ph-offered-by - set to the offeror code
data-ph-resource-type - set to the resource type
data-ph-resource-id - set to the resource ID
These 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.
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.