• Resolved pako69

    (@pako69)


    Hi

    #1 Why I do not see my G.A. script when I look at my source code?
    #2 Is there way to prevent G.A. script to be activated for current users loged?
    #3 how do do you deal with cache plugins ?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Moove Agency

    (@mooveagency)

    Hi there,

    Thanks for your comments. Please see my answers below:

    1. Read more about this in the FAQ Section

    2. This is possible by using our hooks (you can read more about the relevant FAQ section). The script below could be used to load the GA script for logged in users only:

    add_action('moove_gdpr_third_party_header_assets','moove_gdpr_third_party_header_assets');
    function moove_gdpr_third_party_header_assets( $scripts ) {
    	if ( is_user_logged_in() ) :
    		ob_start(); ?>
    		
    		<!-- Google Analytics -->
    		<script>
    		(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    		(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    		m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    		})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    
    		ga('create', 'UA-XXXXX-Y', 'auto');
    		ga('send', 'pageview');
    		</script>
    		<!-- End Google Analytics -->
    
    		<?php
    		$scripts .= ob_get_clean();
    	endif;
    	return $scripts;
    }

    3. Our plugin is compatible with the caching plugins, the scripts are loaded using AJAX, and was tested with multiple caching plugins.

    I hope this helps.

    Thread Starter pako69

    (@pako69)

    Hi

    2. So I assume that I will have to use:
    if ( !is_user_logged_in() ) :

    3. Even with LiteSpeedCache plugin?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Script added to the footer’ is closed to new replies.