Way to add Google Tag Manager code to WP admin areas of Multisite Network sites?

Hi!

I would like to add a chat widget to my network, so my site owners can chat with me and my team (the network admins) to get support.

I have found some software that looks like it might work at: http://www.socialintents.com/live-chat.html But I'm not sure how I can install the script so that it'll appear in all the sub sites admin areas...

I was wondering if you could help me with a bit of code that can add it in via an mu-plugin or something... (or whatever you think is best).

I was thinking of using Google Tag manager to manage this script (and possibly other scripts)... which has two placements, one in the <head> and one immediately after the <body> tag.

Thanks!

  • Ash
    • WordPress Hacker

    Hello Drew

    You can add GTM code or any other js code in the wp admin using the code below:

    add_action( 'admin_head', function() {
    	?>
    	<script>
    		// Here goes the JS script code
    	</script>
    	<?php
    } );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

  • Drew
    • Flash Drive

    Perfect thanks. I found some similar code to use!

    Also, the Google Tag Manager code snippet has two parts; the second part is to be put immediately after the opening body tag (ideally).

    Could you help me do that? I think I found a way to put it in the footer, but if there is a higher-up option that would be great too.

    Thanks very much.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.