Copy link to clipboard
Copied
Dear all,
I have a google analytics script I need to place in the code of my website www.dickensfellowship.nl.
The instructions tell that I must place in under the <head> tag on each html-page. Since my website has many pages, this will take a lot of work. As most pages are connected to a template I thought it was best to put this code in there instead and update the connected pages so that I could save time. However, I'm not sure if this code will work when it's placed in a non-editable region within a page. What's your experience? Your advice?
Silly question, perhaps.
You have no problem placing this code fragment within a TEMPLATE.
If you're using several different templates, depending on the sections of your site, and since you're already using a proprietary aspect of DW, I'd advise you to use a LIBRARY element instead, which you'll then insert into each TEMPLATE. This way, if you need to modify GA's snipet, you'll only have to make one modification, and DW will pass it on to all the templates, and then all the pages.
For my part, I prefer to place this fra
...Copy link to clipboard
Copied
You have a place for Google Tag Manager in your current template. Analytics can go in the same place.
<!-- Include all compiled plugins (below), or include individual files as needed -->By @Nancy OShea
<script src="js/popper.min.js"></script>
<script src="js/bootstrap-4.4.1.js"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2B2L2HYSVP"></script>
<script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date()); gtag('config', 'G-2B2L2HYSVP');
</script>
</body>
</html>
I share your reasoning 100%, but going further if @edinav24550678 uses two distinct templates in the website, a LIBRARY item will provide more flexible encapsulation of your code (see previous comment above)... than copying this code directly into the TEMPLATE.
Copy link to clipboard
Copied
Thank you all for your replies. I've added the google-script on each page via the templates just above the "body"-closing tag and uploaded all pages. I've also added the code to my Library. Just wait a week to see what results Google Analytics will show.