Best practice of embeding Google Analytics 4 to track the incoming traffic

This is broad topic and somewhat related to Concrete CMS.

How everyone deal with Google Analytics code OR you use other third party 1st cookie analytics service?

I have a client whose Google Analytics reports started showing the spike of “Direct” traffic.

My client and I don’t think they have this much percentage of “Direct” traffic.

BTW, We are using a3020’s GDPR add-on.

This add-on hides the tracking code altogether until they click to accept cookies.
I believe this could the reasons of the spike of direct access?


Just a side note: IIRC that package was created by a3020

We switched to using Google Tag Manager, integrated with Iubenda.
This setup simplifies the GDPR, CCPA, FADP, LGPD, … compliance.

1 Like

@mlocati Opps… sorry I thought it was yours.
The GitHub repo was commited by yours… so sorry… I remember now.

I also edited the original text that it was developed by a3020

@mlocati OK. Thanks.



And you also made the add-on for Concrete… cool!

Unfortunately, they don’t provide Japanese service…

We may try to modify GDPR add-on, or try to find alternative service which supports Japanese.


I put together last year an add-on that uses:

It’s complete and well tested, I just haven’t put it on the marketplace or github. You’d be welcome to check it out (and give me feedback on where I should release it!)

The dialogs look like what you see on the demo site above, and here’s the dashboard page:

This looks like a very interesting add-on as I have been looking at building cookieconsent v3 into a current project. I had previously used the a3020 add-on as well but I am not sure if this will be updated to work with version 9.

Would your plugin be able to support the opt-in / opt-out models available in the script config and would the data- attributes all work when adding the tracking scripts through the dashboard?

Whilst it is possible to build this into the theme files the ability to hand over to the client and allow them to manage these scripts would be a real bonus.

I’m using the cookieconsent the way it describes, where the scripts start off as type=“text/plain”, and cookieconsent changes that dynamically when needed to turn them on and off. Code wise, it really just does a find-and-replace on the scripts you paste in, to add the type and data-category attributes.

I’m not 100% of your question here, but whatever data attributes are on your scripts would remain unchanged.

Thanks for the quick response - we have asked to set up cookie options but without following the strict gdpr requirements…

mode: opt-out

This changes the script setup to use cookies by default but still give users preference options to switch off cookies if they want.

The data- attributes are just as you mentioned for data-category or data-service etc. I was looking at this as an extension to the opt-in / opt-out mode settings. It is possible to label a cookie category as ‘analytics’ for example…


or label the category but ignore the cookie preferences to ensure it is still run…


As all of this remains unchanged it sounds like it would work just fine. Thanks again and I will keep an eye out for this becoming available!

I’ve not used the ‘mode’ setting on the add-on so far, I have a feeling it wasn’t there when I built it (as I was using the beta of version 3 of the script, not the full release).

I also haven’t added anything to do with the ! option. That might require more script input fields. That one might be starting to get to more obscure usage.

I’ll factor these in when I next update the add-on. I still haven’t quite decided where to release it to be honest.

Sorry - I didn’t mean to bombard you with feature requests before you have even launched!

I wondered if the mode setting could be a simple dropdown a bit like your Force Consent option with Opt In or Opt Out options.

I don’t think you would need to add anything extra for the ignore ! settings as the script should take care of that. If you add the script in your dashboard setup as recommended…


that should theoretically just work out of the box with no additional config required.

Thanks for taking the time to respond and best of luck with the plug-in development.

I agree that the mode setting should be pretty easy, it’s just another flag.

The issue with the ! option, is that the add-on already takes care of putting those categories in. Note in the screenshot of the dashboard config that there’s 4 boxes to paste in scripts (two categories, both header and footer spots). The idea with these is that you don’t have to add the type=“text/plain” or data-category flags, those are added automatically. All you would do is paste in your normal unmodified script tags.

That makes a lot of sense - removes a lot of unnecessary complexity for the vast majority of use cases. I think hard coding the additional complexity in these rare cases would be the best way forward.

Thanks for explaining your setup. Your add-on looks great though so I will definitely look out for it for some more straight forward use cases.

Hello Mesuva,

Thank you for your useful reply on this topic.

Did you put you addon somewhere to test it ?

Not at this stage - but I think I’ve decided I’ll try to get it onto the marketplace soon (for free). I just want to add a couple more options to it.

The client is going to SaaS route. But Iubenda that mlocati suggested doesn’t offer Japanese languages.

We did the research and found a couple of other services.
Then, we may go with CookieFirst.

Mesuva’s add-on looks awesome, too.