I'm creating a new SXA site and have the requirement to inject Google Tag Manager (GTM) scripts into all of our pages. Unfortunately, the content editors want to manage these scripts (and other similar ones) themselves by adding content items to the content tree.
I know how to do this and inject these scripts into the <body>/<header>
or <body>/<footer>
, but GTM expects one script to be added to the <head>
and another to be added immediately after the opening <body>
tag (which would be prior to the wrapper <div>
).
I looked into doing this using a Metadata Partial Design, but I couldn't find documentation and, while experimenting, I could only figure out how to add <meta>
tags... nor could I figure out how to activate the partial on my pages.
Is it possible to do this out of the box with SXA? If not, where is the best place to start with a custom solution?