Google analytics suddenly stopped tracking - can't figure out why?

Hi, I am hoping you can assist. My google analytics has stopped tracking and I can not determine why, despite back tracking my actions. I have re-run yoast and reauthorised with google and also tried inserting the global javascript tracking code (not sure if done correctly)

Are you aware of any plugin updates that may have caused this?

I’d be most grateful if you could assist.

regards,

Rebecca

Hi There,

Please remove the analytic code under Theme Options > JS.

Then add the following code under functions.php file locates in your child theme instead:

function head_scripts() { ?>
	<!-- Global site tag (gtag.js) - Google Analytics -->
	<script async src="https://www.googletagmanager.com/gtag/js?id=UA-76581533-1"></script>
	<script>
	  window.dataLayer = window.dataLayer || [];
	  function gtag(){dataLayer.push(arguments);}
	  gtag('js', new Date());

	  gtag('config', 'UA-76581533-1');
	</script>
<?php }
add_action( 'wp_head', 'head_scripts' );

Let us know how it goes!

Hi, do you have a video on how to do this?

I reallyy didn’t want to delve into this, just wanted it to work through Yoast as it did last week
Thanks

Hi there,

Please login through FTP then go to wp-content/themes/x-child then you should be able to find the functions.php there.

Edit the file and kindly place the code previously provided at the bottom of the file contents.

Hope this helps.

Do you go via my hosting cpanel? Is that in FTP accounts, can’t find anything relating to ‘wp-content/themes/x-child’

I’m not a developer. Shouldn’t this be feasible via yoast? or something equally straight forward?

Thanks

Hello @HandB,

Thanks for asking. :slight_smile:

I see that you have installed child theme on your website. You can also add the code shared by my colleague from Appearance > Editor > Function.php. Here is a screencast video that you can take a look. https://cloudup.com/cGKKk4uOo0A

If you are not comfortable with codes, then you have the option to use DuracellTomi’s Google Tag Manager for WordPress plugin. I am sharing the tutorial link that you can take a look.

Thanks.

Brilliant Prasant,
Now that’s what I call a helpful answer, please show this to your colleague, Jade, as I think it would be helpful to them! :wink:
Regards,
Rebecca

Okay Prasant - it was a helpful answer but, mysteriously the Editor option is not visible in Appearance and it has been before?? Any suggestions.

I can use the plugin for now but working towards keeping it lite, … eventually

Rebecca

Hi Rebecca,

We’re glad Prasant gave you a better solution in resolving the issue. We always want to give a precise and easy solution for the resolution of the issue. Jade gave you the most easiest way to access the functions.php file. We apologize if you feel that the response is not helpful enough.

Anyways, lest get back to your last issue where in the Appearance > Editor option is no longer available in your WordPress dashboard. This usually happens when the file permissions of the template files were restricted and/or the file editor were disabled. Did you add anything in your wp-config.php that could somehow disable this feature? You might need to check the file permissions in your ftp file directory. This codex might help you: https://codex.wordpress.org/Changing_File_Permissions

Best Regards.