• Resolved Julie

    (@habannah)


    Hi there,

    I use Google Analytics Dashboard to inject my tracking code. There is an option to move the tracking code to the footer:

    add_action('init', 'gadwp_remove_trackingcode');
    
    function gadwp_remove_trackingcode(){
    	if (class_exists('GADWP_Manager')){
    		$gadwp = GADWP();
    		if (isset($gadwp->tracking)){
    			remove_action('wp_head', array($gadwp->tracking,'tracking_code'), 99);
    
    			add_action('wp_footer', array($gadwp->tracking,'tracking_code'));
    		}
    	}
    }

    After inserting this snippet, there was a huge spike in my bounce rate. Removing it returned things to normal. I suspect the problem is because this plugin adds its tracking code to the head as well.

    Would it be possible to introduce an option to move this plugin’s tracking code to the footer? (NB: I already load the script in the footer.) Perhaps a code snippet such as the one above — I imagine that this request doesn’t apply to most users of this plugin, so I can understand if you don’t want to add an option to the settings page in case it confuses people…

    Thanks in advance for considering this!

    https://www.ads-software.com/plugins/reduce-bounce-rate/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi,

    I suspect that the plugin’s code was before the Analytics code you moved to the bottom. There is probably no option to choose where you want to place it.

    If you copy the plugin’s code you see now in the source of your web page you could copy and place it manually in your theme header.php and footer.php. And then you could delete the plugin.

    The plugin doesn’t need any update anyway as long as Analytics uses the same tracking code or WordPress changes the way plugin can add code to a page.
    You’ll be pretty safe when you place the code there manually.

    It could also be that you have two Analytics tracking codes on your website. The first one you have added yourself and the second one that is added by the plugin.

    If this doesn’t help, could you post the link to your website so I can have a look?

    Regards

    Plugin Author Okoth1

    (@okoth1)

    Hi there,

    Yes, posting the link to your website would really help to see what’s going on. Otherwise it’s just guessing. If possible, could you have both plugins active?

    Thanks
    Okoth

    Thread Starter Julie

    (@habannah)

    @wendihihihi:

    I suspect that the plugin’s code was before the Analytics code you moved to the bottom.

    Yes, that’s what I said above:

    I suspect the problem is because this plugin adds its tracking code to the head as well.

    @okoth:

    Of course I’ve got both plugins active. GAD inserts the analytics tracking code, this plugin only adds a few options. How else would you propose I do it? Think of it this way. You say this plugin is compatible with Yoast Analytics. It’s also compatible with GAD, so long as the GAD (read Google Analytics) tracking code isn’t moved to the footer.

    So, I’ve already explained exactly what’s going on. I need to be able to place this plugin’s tracking code in the footer instead of the head. By tracking code I mean the options chosen on the Settings screen.

    Thread Starter Julie

    (@habannah)

    For now I’ve changed add_action('wp_head', 'rbr_st_control_vars', 1); to add_action('wp_footer', 'rbr_st_control_vars', 1);. However, it would be nice if there was a function or filter to do this, instead of directly modifying the plugin’s files…

    Plugin Author Okoth1

    (@okoth1)

    What difference would it make that the vars are in the head or footer? As long as they come before my plugin’s code in the footer it will work.

    Most important is that the analyticsjs.js comes after the GAD analytics tracking code.

    Thread Starter Julie

    (@habannah)

    It caused a huge spike in bounce rate when I placed the Analytics tracking code in the footer. I mean huge, like 60% increase. The vars need to be in the footer when the tracking code is placed there. This returned the bounce rate to normal for me.

    For anyone else using GAD and RBR together and wanting to improve site performance, my solution posted above isn’t quite perfect, because the priority of the rbr_st_control_vars is 1, so it still loads above the GAD tracking code. Changing the priority of the GAD tracking code to 0 solves this. So, in the GAD code I posted in my first message above, it should be this:

    add_action('wp_footer', array($gadwp->tracking,'tracking_code'), 0);

    @okoth1: I’m marking this thread as resolved since I was able to figure it out myself. However, if you do decide to add a filter/function to accomplish this, I would appreciate if you could update me here. Thanks!

    Plugin Author Okoth1

    (@okoth1)

    OK, so obviously it matters that the vars should be in the footer as well when the Analytics tracking code there.

    I’ll make a note of it in case other people have the same question.

    Maybe in the future I’ll add an option to put the vars in the footer as well, but I need to test this thoroughly and I do feel like doing it soonish. But I’ll let you know when the option is there.

    Thread Starter Julie

    (@habannah)

    Sounds good! Agreed that this should be tested by more than one person. Thank you very much for your help ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Moving Tracking Code to Footer Causes Huge Spike in Bounce Rate’ is closed to new replies.