Back to overview
TrackingGoogle AnalyticsCookie banner

Load Google Analytics only after consent, without a single line of code

Tracking scripts may only run once the visitor has agreed. Until now that meant editing your page template, rewriting scripts and hoping for the best. From today you simply enter your measurement ID in Aiara. Here is which services are ready and what to watch out for.

Aiara Team··5 min read
Load Google Analytics only after consent, without a single line of code

A tracking script may only run once the visitor has agreed. There is broad agreement on that sentence, from the Swiss FDPIC guidance to the GDPR. What there is no agreement on is how to implement it without occupying a developer.

From today you only enter your measurement ID in Aiara. The banner does the rest.

Why this used to be manual work

A cookie banner can only block scripts it recognises as blockable. The usual approach looks like this:

<script type="text/plain" data-cookie-category="analytics" src="..."></script>

The type="text/plain" stops the browser from executing the script. After consent the banner swaps the type and loads it. Technically sound, in practice a hurdle: you need access to the page template, you have to know where the script sits, and you must not mistype while rewriting it.

Anyone who receives a measurement ID from their agency cannot do anything with it. Anyone who only operates their content management system through its interface never reaches that place in the code. And anyone who does try often notices a mistake weeks later, when the numbers are missing.

That was the gap: Aiara managed consent, but not the things that depend on it.

What works now

Every domain in the dashboard has a Tags tab. You pick the service, enter your identifier, confirm the category and save. From then on the banner serves the service as soon as the visitor agrees to the assigned category, and not before.

No edit to the source code. Not a single line.

These services are ready

For the following eight services the identifier is enough. Aiara builds the complete script from it, in the form the provider specifies:

Service What you enter Usual category
Google Analytics 4 Measurement ID, e.g. G-ABC1234567 Statistics
Google Tag Manager Container ID, e.g. GTM-ABC1234 Statistics
Matomo Analytics Address of your installation and site ID Statistics
Meta Pixel (Facebook and Instagram) Pixel ID Marketing
LinkedIn Insight Tag Partner ID Marketing
Google Ads Conversion ID, e.g. AW-123456789 Marketing
Hotjar Site ID Statistics
Plausible Analytics Your domain in Plausible Statistics

The category comes pre-filled but can be changed. Only «Necessary» is off the list: it always counts as accepted, and a tracking service has no business there.

If your service is not listed

The Pro plan adds a «Custom script» field. With it you embed any service that is not on the list, from a self-hosted tool to an industry-specific solution. You paste the code, choose the category, and the banner treats it like any other tag.

This option is deliberately reserved for the Pro plan and further limited to organisation admins. Arbitrary JavaScript on a website is powerful, and who may place it should be a conscious decision.

Set up in four steps

  1. Open the domain in the dashboard and switch to the Tags tab
  2. Click Add tag and pick the service
  3. Enter the identifier your service shows you
  4. Check the category and save

After saving, Aiara reports how many cookies of that service were copied into your cookie list. For Google Analytics that is currently seven. This is not decoration: without those entries the category would not appear in the banner at all, the visitor could never agree, and the service would stay silent. At the same time your cookie declaration in the privacy policy is correct.

Three things worth knowing

Withdrawal does not stop what is already running. Anyone who takes back their consent will not see the service from the next page view onwards. On the currently open page it keeps running, because an executed script cannot be recalled. This applies to every consent solution, it is just rarely stated this plainly.

Changes take up to an hour. The banner keeps your settings in the visitor's browser so it does not have to ask on every page view. For someone who has just been there, a new tag therefore appears a little later. New visitors see it right away.

For Google Tag Manager, consent mode is usually the better route. Loading the container only after consent robs every tag inside it of its consent signals. The usual approach is the other way round: the container starts immediately and only runs what consent covers. Aiara points this out in the dialog, and you switch consent mode on in the «Integrations» tab.

For agencies

Anyone looking after client websites knows the request: «Could you quickly add the pixel?» That used to be a ticket, a deploy and a line on the invoice. Now it is a field in the dashboard that your client can fill in themselves if they want to.

Tag management is available in both plans. Only the custom script stays with Pro.

What this means in the end

Consent and the things that depend on it belong together. Maintaining them in two places, once in the banner and once in the source code, was always a source of error. Now both live in one place, and whoever manages consent manages the services too.

See tag management in the dashboard

Share this post

Frequently Asked Questions

How do I load Google Analytics only after consent?

In Aiara you open the «Tags» tab, enter your measurement ID such as G-ABC1234567 and pick the Statistics category. That is all. The banner only serves the script once the visitor agrees to that category. You touch neither the page template nor the script itself.

Which services can I add in Aiara?

Ready to use are Google Analytics 4, Google Tag Manager, Matomo, Meta Pixel, LinkedIn Insight Tag, Google Ads, Hotjar and Plausible. For each of them you only supply the identifier, Aiara builds the rest. The Pro plan adds a field for a custom script so that rarer services are covered too.

Do I need a developer for this?

No, and that is the point. You need the measurement ID of your service and access to the Aiara dashboard. Anyone who previously had to ask their agency to insert a script now does it themselves in under a minute.

What happens when someone withdraws consent?

From the next page view the service stays off. Whatever is already running on the currently open page cannot be stopped: an executed script cannot be taken back. That is true of every consent solution, it is just rarely said out loud.

Will the cookies of the service appear in my privacy policy?

Yes. When you create a tag, Aiara copies the known cookies of that service into your cookie list, with provider, purpose and retention period. They then show up both in the banner and in the generated privacy policy. Without that step your declaration would be incomplete.

What about Google Tag Manager?

That one is a special case. Loading the container only after consent robs every tag inside it of its consent signals. The usual route is consent mode: the container starts immediately but only runs what consent covers. Aiara points this out in the dialog and offers consent mode in the «Integrations» tab.

How quickly does a change take effect?

Immediately for a new visitor. Anyone who has been on your site within the last hour will see it slightly later: the banner keeps the settings in the browser for that long so it does not have to ask again on every page view.

Ready for clean cookie consent?

Aiara handles cookie banners, privacy policies and legal notices for your website — FADP and GDPR compliant.

Discover Aiara