Skip to content
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

Platform: analytics for Flourish embeds in body fields #354

Open
4 tasks
mariacha opened this issue Feb 6, 2025 · 0 comments
Open
4 tasks

Platform: analytics for Flourish embeds in body fields #354

mariacha opened this issue Feb 6, 2025 · 0 comments

Comments

@mariacha
Copy link
Collaborator

mariacha commented Feb 6, 2025

Coming out of #328 now any Flourish items that are Embeds have analytics, but if the Flourish item is embedded within the body, like https://es.wri.org/insights/el-financiamiento-climatico-es-la-historia-mas-importante-seguir-en-2025, flourish analytics do not show.

Dev tasks

  • Create a custom filter that can be added to a "Text format". Africa has an example of one: https://github.com/wri/wri-africa/blob/main/web/modules/custom/wri_africa_entity_share/src/Plugin/Filter/RelToFlagshipAbs.php and you can use drush generate plugin:filter to create your own. Put it into the wri_media module.
  • In the filter, look for if (strpos($embed_code, 'flourish-embed') !== FALSE) { to see if the body contains a flourish embed. If it does, add the script. You can move the if block that starts with if ($media && $media->hasField('field_media_embed_code')) { out of wri_media_preprocess_media and use it here.
  • Add this filter to the "Full Html" and "Unrestricted text" formats and save those config changes back to web/profiles/contrib/wri_sites/modules/wri_media/config/install/editor.editor.full_html.yml and web/profiles/contrib/wri_sites/modules/wri_admin/config/install/filter.format.unrestricted_text.yml respectively.
  • Create an update hook that sets the config from the last step across all IOs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant