Link to home
Start Free TrialLog in
Avatar of John H
John HFlag for United States of America

asked on

Finding the file/plugin that inserted my Google Analytics code?

Hey Folks,

First time poster here...  I need to make a change to my google analytics code on my wordpress site, but cannot figure out how it was inserted.  I've checked header.php, within the child theme, etc.

Is there a way with something like firebug lite i can find the source file that inserted the code (i have other javascripts where i want to find out the how and where of how they were inserted into the page code).  

In essence, I'd like to be able to trace objects in the source code to where they came from, how they were inserted, etc.

Many thanks!!
Avatar of Lucas Bishop
Lucas Bishop
Flag of United States of America image

In most cases a plugin won't hardcode the javascript into a template file.

You'll need to go through your plugin directory to see if there is some kind of "seo" or "analytics" plugin.

Also if you view the source code of your site you may see some hints near the analytics.js file. Like "inserted by yoast seo" plugin.

In essence, I'd like to be able to trace objects in the source code to where they came from, how they were inserted, etc.

Generally, no. This would be a security issue if someone was able to look at all of the plugins you're running on your site. Many plugins have security issues and this would help malicious users track down exploitable sites.
use google tag manager
Avatar of John H

ASKER

@Lucas - i checked all my plugins and both parent theme header and child theme header.  Cannot find what is inserting it.  Do you know of any way to start with the source code and trace the printed material in the source code back to the action/hook that inserted it?

@Stuart - i went and looked at tag manager but could not figure out how it can help me find the origins of my GA code.  Looks interesting, but i dont know how many hours of study i'd have to devote to it to really understand how it works.

Thank you for your replies though :)
ASKER CERTIFIED SOLUTION
Avatar of Lucas Bishop
Lucas Bishop
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
sorry should have been more clear.  If you make the decision going forward to make anything like loading analytic codes, trackers, plugins or anything not specifically to do with that one page then using the google tag manager will allow you to manage them all in one place.

That way you will never again have to think 'where did this one come from?'
Avatar of John H

ASKER

@Lucas - man, thank you for that detailed response, that had to take a good 15 minutes of your time, I so appreciate it greatly.  Gimme some time to work through those suggestions (am smelling widgets).

@Stuart - I get it now, can totally see it's application moving forward, thank you!
Avatar of John H

ASKER

muchas gracias brother!  add this to the knowledge base :)