• Resolved markhhg

    (@markhhg)


    Hi, do you not init the script (var gaProperty = ‘UA-xxxxxx) on the homepage?

    I use Visual Composer to display some products on the homepage and getting ReferenceError: ga is not defined

    Is this a reason?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter markhhg

    (@markhhg)

    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.

    Thread Starter markhhg

    (@markhhg)

    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:

    Google Analytics on the homepage
    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,

    Thread Starter markhhg

    (@markhhg)

    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.

    Plugin Support 3 Sons Development – a11n

    (@3sonsdevelopment)

    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

    Plugin Support Mike Straw

    (@mikestraw)

    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.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘no script init on the homepage’ is closed to new replies.