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 Answer
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.
-
-
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. Aug 9, 2019 at 18:34 -
I open
wp-includes/general-template.php
and see that hook. However, it only containsdo_action( 'wp_head' );
. Where can I trace next?– OokerAug 9, 2019 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). Aug 9, 2019 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– OokerAug 10, 2019 at 8:34