Google Analytics and external scripts

Control when optional scripts can run

Some external services, such as analytics, tracking or marketing tools, are loaded using scripts rather than iframes. When these services depend on consent, they must be prepared so that they do not run before the visitor authorises the corresponding category.

Blocking a script is not the same as blocking an iframe.

With an iframe, it is usually enough to prevent its address from loading before consent. A script, however, may begin executing as soon as the browser encounters it. For this reason, its initial execution must be prevented and Alamarte Cookie Consent Pro must be allowed to activate it once authorisation exists.

1. Identify the category

First determine the purpose of the service you want to control.

A measurement tool may belong to Analytics, while certain advertising or tracking services may belong to Marketing.

2. Locate the code that loads the service

Review how the service is integrated into your site and locate the code responsible for loading it.

This may be an external script, a JavaScript block included directly on the page or a combination of both.

3. Prevent execution before consent

Code that depends on an optional category should not run normally before authorisation exists.

If the browser executes the script immediately when the page loads, Alamarte Cookie Consent Pro can no longer prevent that initial execution.

4. Allow activation after consent

Once the corresponding consent has been authorised, content prepared for that category can be activated according to the configuration implemented on the site.

If the category remains rejected, the service should not run.

Google Analytics

If you use Google Analytics and have determined that its loading should depend on consent, make sure that the corresponding code does not run before the visitor authorises the category defined for that service.

Review all fragments related to the integration. On some sites, more than one code block or an additional extension may be responsible for inserting Google Analytics.

Modifying only one fragment is not enough if another part of the site continues to load the service separately.

Scripts added by extensions

Some Joomla! extensions automatically insert external scripts into the page.

In these cases, check whether the extension allows you to control when the service is loaded. If the script is inserted and executed before Alamarte Cookie Consent Pro can intervene, the integration method will need to be reviewed.

Scripts added manually

If the code was added manually in a template, module, article or custom code field, locate exactly where it is placed before modifying it.

Avoid keeping a second active copy of the same script elsewhere on the site.

Test without accepting

Open the site in a private or incognito window and initially do not authorise the category associated with the service.

Check that the script or external service does not activate before consent is obtained.

Test after accepting

Authorise the corresponding category and check that the service can begin working correctly.

Also test after changing the preferences again to verify that the behaviour is as expected.

Check that the service is not being loaded elsewhere

The same service may be integrated from different locations: the template, a module, an extension, a tag manager or custom code.

If it continues to load before consent, review the entire site to locate any second integration that remains active.

Important: the exact way to prepare a script depends on how the service is integrated into the site. Do not modify code from an extension or template without first identifying which component is performing the load and how it can be controlled safely.

trustpilot horizontal

© 2026 Alamarte Ingeniería
Joomla! Design & Development
colombia CO CO

Alamarte Ingeniería Web
Trustpilot
Joomla!

Select your language

ALAMARTE - Ingeniería Web
Cookie preferences saved.