0
I’m trying to change the code Analytics of a Wordpress blog. However, I don’t have much knowledge and I’m having trouble figuring out how the code was added.
From what I research, I managed to figure out 3 ways to add the code Analytics in wordpress. However, none of these forms have been used and yet it has an Analytics code already added.
The shapes I found are:
- Using a plugin (I looked at the plugins and did not find the Google Analytics or any other plugin with the word "Analytics").
- Inserting the code into
header.php
theme (The theme does not have the script for the Analytcs tag. But it does have a PHP function that might add something:<?php wp_head(); ?>
However, I’m not sure if the code is inserted by this function). - Creating a new function in the file
functions.php
(I searched this file and it also has no script for Analytics)
These were the only ways I found to add Analytics code in Wordpress. But from the looks of it, the code was added otherwise.
There are other ways to add Analytics code in Wordpress?
Your theme has some plugin that is called Yoast ?
– hugocsl
Yes @hugocsl. It has the plugin "Yoast SEO Premium".
– alan
Is there a link to this site? The Google script you are looking for is at the top or at the bottom of the page ?
– hugocsl
Yes. It’s posted! the code appears at the head of the pages. It seems to be added by the "wp_head()" function of the header.php file.
– alan
Guy goes in theme, in Appearance > Edit > Find header.php must be inside it
– hugocsl
It’s not. Like I said upstairs. In the header.php of the theme, I only have the wp_head() function. I even added the new code of la Analytics and mine appears just below the old on the page. Leaving it with two codes of Analytics. Above the script tag I added there is no script tag. everything is added running. That’s why I think it’s this "wp_head()".
– alan
can be YOAST, disable it and see if Analytics remains: Yoast Plugin > Features > Disabled and save changes
– Hebert Lima
I don’t have much knowledge in wordpress. So I don’t feel safe in disabling this plugin. Because it might be making other settings. I will search and study a little more about it before. To not affect the functioning of the blog.
– alan
Try the brute force: download all the files in a folder and search for Windows by searching for the term "Analytics" inside the files.
– Sam
@The funny thing is, I did this, and as amazing as it sounds, it’s not in the files. The old Analytics code only appears on the HTML cache pages of the blog. What makes me strongly believe that this setting comes from some plugin!
– alan
If there were go disabling each plugin at once and checking.
– Sam
@dvd I intend to do this, but calmly. As I do not have much knowledge in Wordpress, I intend to study a little about each plugin before disabling. To know the effect of this on the blog. I’ve already added the new code, so it’s at least already being tracked. My problem now is that it has two Analytics codes. The old and the new, so I need to remove the old and leave only the new.
– alan
I understood, but what I meant was you disable (even if it affects the blog) a plugin, give refresh on the blog and see if the old Analytics is gone; if not, enable the plugin again and part to other doing the same thing.
– Sam
@Alan If you use a linux server, go to the root of your project and run the following command:
grep -irwn "analytic*" --include "*.php"
. So it will list all the files that contain that word. Another alternative is to search the Analytics code in the database, so you can delete it; If it still does not solve, it is probably encrypted and you will need to check plugin by plugin.– Valdeir Psr
@Thanks Valdeirpsr. But I did the verification process (search) on all the blog files in sublime text. So I strongly believe that this setting is coming from some plugin. I will test every one of them calmly and when I find I will post here what was!
– alan
I did a lot of research regarding your problem, and almost everywhere the tip is the same: disable the plugins and go enabling one by one (giving refresh before the blog) to see if appears the old Analytics. By enabling a plugin again and appearing the Analytics, you will know that it is it that is generating. But this has to be a quick process, even if the Blog if Sconfigure for a few moments, I think it’s not a big problem for you to find where this comes from.
– Sam
@dvd thanks for the effort in trying to help me. But to my surprise the setting was within the configuration screen of the theme itself! :)
– alan