Tracking codes don't work in Pro

Hi, I’ve tried adding tracking codes to my Pro theme with no success. I used the Insert Headers and Footers plugin since there is no way to directly edit php files with the theme, but it still fails to work. I am copying the codes exactly (for Google tracking and for Extreme Tracking). What else can I do? This is enormously frustrating.

Hi John,

Thank you for reaching out to us. If you’re trying to add Google Analytics tracking code then you can do this with our Google Analytics Extension to add the code. To know how it works please see https://theme.co/docs/google-analytics

Another way to add the codes in the header or footer of your site is through wp_head action hook (to add the code in the <head></head> section see https://developer.wordpress.org/reference/hooks/wp_head/) and wp_footer action hook (see https://developer.wordpress.org/reference/hooks/wp_footer/)

Now to use them, first you need to you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

After setting up the child then add the following code in your child theme’s functions.php file:

add_action('wp_head', 'add_tracking_code');
function add_tracking_code() { ?>

<!-- Paste your tracking code here -->

<?php } ?>

The above code will add the code inside the <head></head> section of the theme. You might want to take look here as well https://theme.co/docs/actions-filters-and-hooks

Hope this helps!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.