Not sure if this the best approach but I’m currently adding Google Tag Manager (GTM) to a Volto project by shadowing components/theme/Header/Header.jsx
and inserting a Helmet
component. I import it like this:
import { Helmet } from '@plone/volto/helpers';
Here’s an example of how I’m adding the GTM script:
<Helmet>
<script>{`(function(w,d,s,l,i){...})(window,document,'script','dataLayer','GTM-XXXX');`}</script>
</Helmet>
This approach works, but it requires a full rebuild of the frontend to deploy it. Is there a more efficient way to handle GTM in Volto without needing a redeploy?
Any advice is much appreciated!