Google GA4 tag, how to install on site?

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

8/14/2022 2:40:31 PM
Gravatar
Total Posts 26
regards, Svein-Martin Holt Norway

Google GA4 tag, how to install on site?

I wonder if any of you have installed the Google GA4 tag on a site and know how to do it?

According to the instructions from Google there should be a tag added to each page on the site, after the <head> item, an example here(the code is changed to xxxxxxxx and I have deletred the <> characters in the code so it can be shown here):

Google tag (gtag.js) 
script async src="https://www.googletagmanager.com/gtag/js?id=G-4Dxxxxxxxx"/script
script
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-4Dxxxxxxxx');
/script

 

Anybody know how to implement that on the site, please?

Regards, Svein-Martin Holt
platelayer.com

8/15/2022 10:38:08 AM
Gravatar
Total Posts 2239

Re: Google GA4 tag, how to install on site?

Hello,

It's very simple to add GA4 to a mojoPortal site. All you need to do is open the layout.master for your skin and add the code you referenced to the bottom of the <head> section of the html.

If you look at the source on the i7MEDIA website, you'll see our GA4 tag just above the </head>

We're finishing up on our work to get the pgsql, sqlite, and mysql database layers in sync with our mssql database layer. Once we have done that, we'll be able to make a public release which includes a feature to add scripts to the site without editing the layout.master.

Thanks,
Joe

7/24/2023 3:56:35 PM
Gravatar
Total Posts 2239

Re: Google GA4 tag, how to install on site?

The latest release of mojoPortal has a couple options for this. 

  1. Use the built-in GA4 support by adding your GA4 ID to the "Google Analytics Account Code" setting under Administration > Site Settings > API Keys.
  2. Add the javascript code from Google Analytics to the head element in your skin.
  3. Use the Custom Content options in Site Settings.

Thanks,
Joe