0

I have looked at all the file in my theme and its parent theme, including the header.php and footer.php, but I still can't find the Google Analytics it put in. Do you know how to find its location?

1

It doesn't change the theme itself. It uses a hook to insert the tracking code. View the source of one of your outputted front-end pages, and you'll see the JS injected in there somewhere.

  • so where is that hook inserted? – Ooker Aug 9 at 18:24
  • It's the wp_head() hook. This hook is included in all themes as a standard way for plugins to include additional code, like your GA tracking code. – WebElaine Aug 9 at 18:34
  • I open wp-includes/general-template.php and see that hook. However, it only contains do_action( 'wp_head' );. Where can I trace next? – Ooker Aug 9 at 18:51
  • What exactly are you trying to trace? Hooks work by existing in various places in Core and themes, and sometimes plugins. Once a hook exists, a theme or plugin author can add an action or filter (depending on the type of hook) and by doing so, their code will run at the time that hook is called by Core (or the plugin or theme, whichever set the hook in place). – WebElaine Aug 9 at 19:59
  • I see. It seems that I need to understand more about hooks. Anyway, is it correct that using this plugin will make Google Tag Manager turns red? I see that it detect Google Analytics code, but I haven't put any tag into the container yet – Ooker Aug 10 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.