• Hi there,

    in order to comply with the GDPR, I’m using Iubenda.

    Unfortunately that plugin is not able to block the Google Analytics scripts because they’re loaded too soon.

    Is there a way to lower the priority of these script inserted by Google Tag Manager for WordPress?

    <script type="text/javascript" async="" src="//www.googleadservices.com/pagead/conversion_async.js"></script>
    <script type="text/javascript" async="" src="https://www.google-analytics.com/analytics.js"></script>
    <script async="" src="//www.googletagmanager.com/gtm.js?id=GTM-W7KS34V"></script>

    I tried the following code, but it lower the priority of the tags:

    function genuss_change_script_priority() {
    	remove_action( 'wp_head', 'gtm4wp_wp_header_top', 1);
    	add_action( 'wp_head', 'gtm4wp_wp_header_top', 5, 0 );
    }
    add_action( 'init','genuss_change_script_priority' );

    Thanks a lot,

    Simone

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Simone,

    We should separate code execution order on the backend (in PHP scripts) and on the fronend (JavaScript codes).

    Within Google Tag Manager (so not in this plugin, but in Google’s code) all tags are executed async, thus you have not much control on code execution if you change the priority of WordPress hooks.

    What I would do is to ask Iubenda whether they have any kind of integration with Google Tag Manager? This can be a simple datalayer event which is fired by the scripts of Iubenda when the tool is loaded. You can then change triggers in your GTM container from “All pages” to something else to delay execution until your GDPR consent manager has been loaded.

    Thread Starter Simone Montanari

    (@semikola)

    Hi Thomas,

    thanks for the answer. I’ll look into the solution you proposed.

    Cheers,

    Simone

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Delay loading scripts’ is closed to new replies.