Stape
Search
Try for free
Free

Custom GTM and GA4 Loader

Custom Loader helps make Google Tag Manager and Google Analytics 4 scripts more resistant to ad blockers and ITPs by modifying gtag.js and gtm.js loading path. Moreover,  a Custom Loader and Custom Domain help set first party cookies and prolong cookie lifetime!

How to set up Custom Loader

1. Log in to your Stape.io account.

2. Choose the container. Click on the Power-ups sections, and next to the Custom Loader, hit the Configure button.

custom loader power-up

3. Add the following settings for Custom Loader:

Domain - select the necessary domain from the list of domains connected to your container. 

Web GTM ID - add web Google Tag Manager ID. Find out how to find web GTM ID in our guide.

Platform - the custom loader code differs for each platform. 

custom loader power-up

3.1 If you select the “Other” platform, you will be given a JavaScript code to use on your website instead of the standard GTM loader.

Other option on Custom Loader
Other option on Custom Loader

Note: If you are using apps and plugins developed by Stape, they have fields that allow you to set up a Custom Loader directly within the app/plugin/extension. 

We, at Stape, have developed apps, plugins, and extensions for the following platforms:

4. Additional settings:

  • Data Layer variable name - specify if you use a non-standard ‘dataLayer’; otherwise, leave it empty.
  • Generate with CDN - available only if the selected domain has an active Stape CDN. If enabled, the container will be loaded from a server closer to your website visitors.
  • Use the original GTM code - if enabled gtm.js will not be replaced and your GTM container ID will not be encrypted. With this option enabled, the protection against adblockers will be much lower.
  • Generate with Cookie Keeper - available if have the Cookie Keeper power-up active. If enabled, the code will also add Cookie Keeper operation and GTM loading.
  • User identifier type - available if the ‘Generate with Cookie Keeper’ option is active. The recommended method of identification is Cookie. For more details, see the article on how to choose a User Identifier.
additional data

5. Click “Generate”. You will then be given instructions on how to add a Custom Loader to your site. Please note that just generating it doesn't do anything; you also need to make the necessary changes on the website (add code) or in the Stape applications if you use any.

When adding the Custom Loader to the site, make sure you also remove the standard GTM loader if you have one.

Test the setup

To check if everything works correctly, click the right button on any website page, → Inspect,” and go to the “Network” tab. Then, enter your custom subdomain.

If everything is correct, you should see the Google Tag Manager request URL and Status Code 200 OK, as shown in the screenshot below:

Test the setup

Benefits of Custom Loader

1. Sets 1st party cookies. 

2. Prolongs cookie lifetime.

3. Makes GTM and GA4 resistant to AdBlockers and ITPs.

4. Keeps your data tracking intact.

Use cases of the power-up

We have more than 100 000 happy clients

Try Stape for all things server-sideright now!