• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Question about placing a google analytics script on your html-page

Community Beginner ,
Mar 14, 2024 Mar 14, 2024

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.

 

Views

471

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 14, 2024 Mar 14, 2024

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

...

Votes

Translate

Translate
Community Expert ,
Mar 15, 2024 Mar 15, 2024

Copy link to clipboard

Copied

quote

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 -->  
<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>
By @Nancy OShea

 

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 15, 2024 Mar 15, 2024

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines