Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #379535

    Hey,

    I want to avoid using the google analytics tracking code when using the admin.
    I looked around the code and found that the function handling the tracking code is avia_get_tracking_code for building the code and avia_print_tracking_code for printing it.

    I would like to modify my child theme so the printing of the code will only occur when using non logged in users but there is no way to replace only the printing (avia_print_tracking_code) – in order to do that I will need to override the avia_get_tracking_code (which I don’t want).

    Is there a better way to do it or is that the only way?

    #379802

    Hey Zohar!

    You could try this.

    add_action( 'init', 'enfold_customization_remove_ga', 20 )
    function enfold_customization_remove_ga() {
    	if ( is_user_logged_in() ) {
    		remove_action('wp_head', 'avia_print_tracking_code', 100000);
    		remove_action('wp_head', 'avia_print_tracking_code', 100000);
    	}
    }

    But overriding the function would work just as well.

    Cheers!
    Elliott

    #381105

    why is the remove action written twice? is that correct?

    #381107

    i think the second one should have been “wp_footer”.

    #381449

    Hi!

    Yes, you’re correct. Replace the code with this:

    add_action( 'init', 'enfold_customization_remove_ga', 20 )
    function enfold_customization_remove_ga() {
    	if ( is_user_logged_in() ) {
    		remove_action('wp_head', 'avia_print_tracking_code', 100000);
    		remove_action('wp_footer', 'avia_print_tracking_code', 100000);
    	}
    }

    Cheers!
    Ismael

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.