Jump to content

How do I add GA4 scripts to the Header


Rugby1847
 Share

Recommended Posts

Just inherited a ProcessWire site and have never used it before.  I am trying to add the GA4 script to the header. 

I attempted to create a textarea field and inserted that in in an Admin page with Global Site Settings.  This field appears, but when i place the snippet it is not rendered in the live page  Am I missing a step?

Thanks....

Link to comment
Share on other sites

The fun, and not-so-fun (in this regard) thing about ProcessWire is that it gives a lot of control over how to use it to the developer(s) creating the website(s) with it. It's a CMS/F (Content Management System/Framework). The reason I state this is because doing what you did, depending on how the original developer handled things, could work. Typically though, when you create a field, you then add that field to a template (or multiple templates) you wish to use it in, and then with the page(s) that are assigned that template, you reference it from within the PHP code of the template file(s).

There are ways to create globally accessible fields so that it will always be accessible to editing from the interactive administrative back-end, but with something unlikely to be changed by a standard end-user (such as a Google Analytics script), you should be able to just edit the template files directly, and hopefully the prior developer made it easy enough to identify which file contains the code for the standard HTML headers.

There are some confusing jargon when you're just getting started with ProcessWire:

Templates, and Pages

There are "template files" and "[system] templates".
...and "pages" in ProcessWire are essentially units of storage, since nearly everything is a page within the system, essentially a custom-named object that docs refer to. So you create a "page" and usually refer to "$page" objects, but $page objects can have fields (properties that hold values) that are also $page objects. 😄 

Here's a good place to start:

https://processwire.com/docs/tutorials/hello-worlds/

If you'd prefer a video walkthrough, although it's a bit advanced, it's recent and does also go through the basics.

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...