Avatar of John H
John H
Flag 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!!
AnalyticsWordPressWeb Development

Avatar of undefined
Last Comment
John H

8/22/2022 - Mon
Lucas Bishop

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.
Stuart Dryden

use google tag manager
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 :)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Lucas Bishop

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Stuart Dryden

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?'
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!
John H

ASKER
muchas gracias brother!  add this to the knowledge base :)
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.