It looks like it’s because of
if ( is_woocommerce() || is_cart() || ( is_checkout() && ! $display_ecommerce_tracking ) )
in your code ?
Plugin Support
John Coy a11n
(@johndcoy)
Automattic Happiness Engineer
Hi @markhhg
The script is added to the header. You’ll have to contact a developer if you want to exclude it from specific pages. You might want to check out our advanced WooCommerce Community in Slack:
http://woocommerceslack.herokuapp.com/
or the Advanced WooCommerce Facebook Group:
https://www.facebook.com/groups/advanced.woocommerce/
There are many developers gathered in those communities, including the authors of our plugins.
I do not want to exclude the script from specified pages – I need to make sure it’s added on each page, homepage including
Plugin Support
Doug – a11n
(@dougaitken)
Automattic Happiness Engineer
Hey @markhhg
I’ve taken a look at my own site that uses this plugin and the script is shown:
Link to image: https://d.pr/i/zcCn1Y
I use Visual Composer to display some products on the homepage and getting ReferenceError: ga is not defined
It sounds like there is a conflict with how Visual Composer is setting up this page or displaying the products.
For reference, my “homepage” is set as the Front Page and I use Storefront.
Thanks,
On your website homepage, is there function ga() defined?
Plugin Support
John Coy a11n
(@johndcoy)
Automattic Happiness Engineer
Hi @markhhg
The specific function to add the Google Analytics ID is added to the header which by default for most themes is included on the homepage. The problem may or may not come from Visual Composer but you can try switching back to a default theme like Twenty Twenty and disabling all plugins except for WooCommerce and WooCommerce Google Analytics Integration to see if this resolves the issue.
Here is a link that better outlines that process:
https://docs.woocommerce.com/document/woocommerce-self-service-guide/#section-4
If this fixes the issue, then re-enable each plugin one at a time, then the theme, until you find the one that’s causing the conflict.
Hey @markhhg,
In order for the tracking code to display on the home page, the is_woocommerce
conditional has to return true as you mentioned. That will require either a WooCommerce shortcode or block to be used on the page.
You can test that out by adding a quick [products]
shortcode to the content of the page. Then see if the tracking code is displayed. I would try it out with the regular editor instead of a page builder to make sure it is picked up successfully.
Let us know what you find out.
Cheers
Hi @markhhg ,
We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.