Google Analytics code site-wide in ?

Hey guys,

Looking at step 3 on the Analytics setup page: https://wiki.foxycart.com/v/2.0/analytics

We have our analytics.js in the site-wide so it loads for all pages.

But when we cache our URL and update our FC templates, I'm assuming this also pulls in the GA analytics.js? And perhaps it causes some problem?

If so, does this mean we need to only include the GA script on each page manually and not site wide?

Thanks.

https://botanicalcraft.com/

Comments
  • fc_adamfc_adam FoxyCart Team
    @Epotratz,

    Our GA integration will already include the GA initialisation code on the cart, checkout and receipt templates - so you definitely won't want to include those on your own custom templates for those pages. You will want to include the GA initialisation code on all of the pages on your side though.
  • @fc_adam

    I just saw that FC admin has an option to embed GA code. Im guessing I can just keep that turned off? So I can just let my custom template files inject GA code into cart, checkout, and reciept?
  • fc_adamfc_adam FoxyCart Team
    @Epotratz,

    The admin checkbox for including the GA initialisation code, if checked, will include that on your own website via loader.js. No matter if that checkbox is checked or not, we will always include the initialisation code on your cart, checkout and receipt.
  • @fc_adam Ok got it.

    By "initialisation code" I assume your talking about analytics.js?

  • EpotratzEpotratz Member
    edited February 1
    @fc_adam,

    Also, I recall Google recommending the analytics.js code be put in the <head> but the FC code is supposed to go before the </body> tag.

    If I turn on GA loading via FC loader.js, should I just put it in the head?
  • fc_adamfc_adam FoxyCart Team
    @Epotratz,

    Yeah that's right - by initalisation code, I'm meaning the code that GA provide for loading analytics.js.

    In terms of placement - with how our loader.js functions, it doesn't give you any big difference between placement in the head or right before the end body tag. Our javascript is designed to be loaded as one of the last items on the page - so no matter where you place it, that's when it'll generally load. As the GA code we include is a part of that, it'll be loaded later as well.

    For the most accurate reporting, you would want to load GA separately, and as Google recommends, include it in the head.
Sign In or Register to comment.