The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Google analytics not tracking to cart (but conversion is showing on receipt page)

flinx777flinx777 Member
in Help edited January 2016
We just did a foxycart upgrade from 0.71 to 2.0 and installed the GA code per the Foxycart documentation for 2.0

Here is the response from the client:
So the analytics code is firing off an event, but can't trace it back to the source click (say an adwords ad or organic search) because we lose the referrer/full query string in URL when going from -> checkout -> where the conversion event actually fires.
I can whisper the store name if you need it.
  • fc_adamfc_adam FoxyCart Team

    If you could whisper me the store in question, I'll take a look for you.
  • Hi, looks like flinx777 didn't reply to this thread, but I am the client in question. My Store is

    I emailed GA support, and they told me the issue is with cross-domain tracking. I read the FC wiki which says DO NOT ADD GA CODE to receipt or checkout template, but GA support is saying I need to modify the GA code both on my site (, in the footer.php) to support cross-domain tracking, AS WELL as on the destination domain ( I just did the modifications on my domain, but haven't messed around with the checkout and receipt templates yet...

    I can't imagine I'm some odd corner case, so I'm sure there is a correct way of doing this and FC has seen this issue before.

    Here's the text from GA support:

    I firstly apologize that I missed your second question. Yes, It might be be a problem if the conversion goal is on a different domain. As you mentioned that your website is but then once they start and go through checkout it becomes or /receipt in this case I would suggest you to go for cross domain tracking.

    To set up cross domain tracking for multiple top-level domains, you need to modify the Google Analytics tracking code on each domain. You should have a basic knowledge of HTML and JavaScript or work with a developer to set up cross domain tracking.

    Set up a property in your Google Analytics account.
    For cross domain tracking, set up one property in your Google Analytics account. Use the same tracking code snippet and tracking ID from that property for all of your domains.
    You need to edit the tracking code snippet for cross domain tracking to work. If you haven't already included the snippet on all your webpages, you might want copy and paste it into a text editor before continuing with the instructions here. This way, you only have to make the changes once before including the modified snippet on all your webpages.

    Edit the tracking code for the primary domain.
    Find the create line in the snippet. For a website called, it looks like this:
    ga('create', 'UA-XXXXXXX-Y', '');
    Make the following changes to the snippet (the changes you need to make are in bold red text):

    ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', [''] );
    Remember to replace the example tracking ID (UA-XXXXXX-Y) with your own tracking ID, and replace the example secondary domain ( with your own secondary domain name.

    This is what this looks like in full context:

    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })
    ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', [''] );
    ga('send', 'pageview');

    Edit the tracking code on the secondary domain.
    Find the create line in the snippet. Make the following changes to the snippet (the changes you need to make are in bold red text):

    ga('create', 'UA-XXXXXXX-Y', 'auto', {'allowLinker': true});
    ga('require', 'linker');
    ga('linker:autoLink', [''] );
    Remember to replace the example tracking ID (UA-XXXXXX-Y) with your own tracking ID, and replace the example primary domain ( with your own primary domain name.

    The tracking code snippet must contain these changes every place it appears on your secondary domain.

  • fc_adamfc_adam FoxyCart Team

    Thanks for posting that update.

    The GA support team is correct that cross domain support needs to be added, and while the steps they detailed are correct, they're not correct for FoxyCart with how we handle the add to cart functionality.

    Instead, we handle it as part of our standard integrations - so if you follow those exactly, everything should be good to go.

    I've taken a look at your store (thanks for including that), and I see you're on 2.0 and you've enabled the Google Analytics functionality correctly. So that means that FoxyCart is automatically adding in the Google Analytics code to your cart, checkout and receipt templates for you - that's why our instructions say to not add your own GA code there.

    Looking at your site, you're including GA correctly there, as well as our loader.js file which adds in the FoxyCart functionality. With our inbuilt 2.0 GA functionality, that also adds some extra Google Analytics code through the loader.js file. That functionality adds some code which adds the users Google Analytics client ID value to their cart session - which is what we use to connect with their same session on a different URL. From my tests, that is working fine.

    So all of that said - I think the issue will be a configuration setting in Google Analytics - specifically the "Excluding Referral Sources" option. I'd recommend following through this section and confirming you've completed all the set up steps for your Google Analytics account:

    If those are already configured correctly - let me know and I'd be happy to take another look.
  • Thanks @fc_adam
    When you examined my site, I assume you looked at the GA code in the footer. When you say "im including it correctly" did you notice the cross domain support? As that was most recently added this week...before then, it wasn't there. I guess I just want to confirm that 1) i need to manually add cross domain support on my website and 2) I don't need to do so on my foxycart templates served from

    If that's true, then I should be a-OK. I haven't had any recent sales come from AdWords campaigns but next time I do I will trace in Analytics to determine if the conversion is correct, and (the real problem) the analytics conversion was correctly attributed in AdWords.

    Also, confirmed that my Analytics setup is, and has been set up correctly since mid December when @flinx777 and his team upgraded to 2.0.
  • fc_adamfc_adam FoxyCart Team

    You don't need to include any cross-domain code yourself for Google Analytics to get it working with your FoxyCart store - we take care of making sure it's tracked correctly.

    You can test it now yourself - simply load up your Analytics profile in real time, and watch yourself as you enter and move around the site - you should see it tracking your correct referrer and then see that maintained as you move to the cart/checkout.

    Just to confirm - your FoxyCart store domain and your own website is in the excluded referral sources?
Sign In or Register to comment.