Google analytics not showing in the source code

Hi,

I configured Google analytics but the source code of the page does’t show ga.js or the tracking code.
My URL is https://tarekrabaa.com

I have added another tracking code to my other sub-site https://tarekrabaa.com/en/

Plz help

Hi There,

Thanks for writing in! Could you please try utilizing this plugin (https://wordpress.org/plugins/insert-headers-and-footers/) to add your Google Analytics code and see if that helps.

Thanks!

1 Like

Hi,

i installed the plugin. still not working.

I used this plugin Google Analytics Dashboard for WP (GADWP) then it works. But it is a heavy plugin which slow down the site.
I installed this plugin GA Google Analytics with faster performance but i don;t know if it is OK,

Is there any other solution without plugin?

Your plugin is not working.

Thx

Hi @tarekr,

Yes, I will forward this thread to our developer so that they could look on that plugin.

You can check this link below on how to use google analytics without using plugin.

Hope it helps.

Let us know how it goes.

Thanks.

1 Like

Parse error: syntax error, unexpected end of file in /home/tarekrab/public_html/wp-content/themes/pro-child/functions.php on line 125

This what i get when i copy the code.

Not Working.
Myy Website is without google analytics now

rgds

I added the code to the global website JAVASCRIPT and it works now. But i don’t know if this is safe!
Is there other options than google analytics?
The solution i applied is not detected by testing SEO tools online.

Hello @tarekr,

Thanks for updating the thread. :slight_smile:

Have you tried adding the solution mentioned in second thread? Please try it out and let us know how it goes. Please add following code in child theme function.php file.

function third_party_tracking_code() { ?>

  <script>
   
  // Google Analytics.
  </script>

<?php }

add_action( 'wp_head', 'third_party_tracking_code' );

Replace // Google Analytics. with analytics code.

Thanks.

Hi,

I added this function. It works but only for GTAG. Universal analytics don’t appear.
Do i need to activate the PRO plugin? or no need for google analytic plugin?
Is there a light plugin that can work efficiently without slowing down the website?

Hi Tarek,
I’ve checked your website now and I couldn’t find any Google Analytics code added, what I recommend is to follow the method mentioned here by my colleague Prasant, then wait for 24-48 hours if Google Analytics still can’t verify the code, then please provide us with WordPress Dashboard login details in a “Secure Note” so we can investigate this issue.

Thanks.

1 Like

I re-added the code but can you check it if is OK

thx

I did a quick check and I can see the code is added incorrectly, the code syntax isn’t correct.

You can’t open a <script> tag inside an already opened one, this is incorrect example:

<script>
     <script>

The correct one is:

<script>
your first script here
</script>
    
<script> //then you can open a new tag :) 

I will add the correct code you need to add in functions.php file in a Secure Note, so you can just copy and paste it.

Thanks.

1 Like

added. Would you plz check it again,
I think it works but it is very heavy on the website, I lost 4 points on speed.
Is it in header or footer?
Do i need to activate Pro plugin for GA?
Regarding my subdirectory url: https://tarekrabaa.com/en/ do i need to add a code or what i did is once for all?
With this code i will see the traffic only from google analytics account or it will appear on Wp admin?

thx

Hey There,

The correct code is this:

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

<?php }

add_action( 'wp_head', 'third_party_tracking_code' );

You do not need to activate GA extension in Pro theme. If https://tarekrabaa.com/en/ is a separate installation, you will also need to add the code in that installation.

GA will only monitor the traffic of your site homepage and other site pages excluding the WP admin.

Hope this helps.

1 Like

Hi,

It works but it is heavy and reduces the speed of my website 3 to 4 points.

thx

Hi there,

It’s only normal, the more you add, the more it requires loading time. Plus, the resources are pulled from Google which you have no direct control. It’s up to you if you’ll continue using it, or not.

Another thing is, google usually complains about the scripts that are even from them and only embedded to the site.

Thanks!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.