-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#328: add flourish analytics to pages with embeds. #344
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code works great on embeds in the body and doesn't fire when there are no embeds on the body, so that's all working as expected! I did think of alternative cases that I didn't pass on in the first place, but I think the solution I put inline in the code should work.
modules/wri_seo/wri_seo.module
Outdated
@@ -45,6 +46,44 @@ function wri_seo_page_attachments(array &$attachments) { | |||
break; | |||
|
|||
} | |||
|
|||
// Check for Flourish embeds. | |||
if ($node->hasField('body') && !$node->get('body')->isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Limiting this to the body field won't work in all cases because sometimes embeds are possible as other fields:
https://pr-1263-wriflagship.pantheonsite.io/data/world-greenhouse-gas-emissions-2021
But if you move the embed code to be at the media level and target the field_media_embed_code
field, it should work in all cases. You could use the existing functions in wri_media
-- either wri_media_preprocess_field
or wri_media_preprocess_media
(there's already some stuff in there about field_media_embed_code
in that second one).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes! I like checking wri_media_preprocess_media() - it feels more lean than slogging through all the body fields. I moved everything into wri_media to keep things tidy and removed the .libraries.yml
entry b/c I'm doing a direct embed of the script into the head.
What issue(s) does this solve?
Flourish events should have extended analytics
What is the new behavior?
Profile requirements:
Site-level pull requests for testing. Only merge when these PRs are approved:
Create or update any site-level pull requests following the documentation
Checked on develop (TA to do)