Documentation You are here: start » v » 2.0 » analytics

Store Analytics

Add analytics and tracking libraries to your FoxyCart store to discover how customers interact with your site.

Google Analytics (Universal Analytics) Ecommerce Tracking

Requirements

  • You must be including loader.js (as found on the 'Sample Code' section of your store's administration) in your website template (do not include this in your cart, checkout, or receipt template). If you're not sure if you are, you can view your website source to confirm.
  • Your products should use the SKU parameter in Google Analytics, which is the code parameter in FoxyCart. If your products do not include a code value (as passed to FoxyCart) FoxyCart will attempt to generate one from the name attribute, but FoxyCart will not take into account duplicate product names, which can clobber your data. If you are not using the code parameter for your products, this Google Analytics tracking may not work correctly.
  • All your add-to-cart links and forms must point to https://your_foxycart_domain with the https (and not http).

Other important Google Analytics stuff

  • We strongly recommend setting up a separate Google Analytics profile to test with. This setup can be tricky, it can't be confirmed immediately because Google Analytics has a delay on reporting, and if you use your primary profile it may dirty up your data (which you cannot undo).
  • This is all for analytics.js and not urchin.js or ga.js. If you're using an older Google Analytics profile type, we recommend upgrading to the new Universal type.

Known Issues and Limitations

  • This code may not work correctly if you're doing direct-to-checkout (cart=checkout) links originating from outside the site being tracked by Google Analytics. For instance, if you have cart=checkout links in an email, the referrer or campaign may not be maintained. If this is an issue for you please let us know.

Setting Up Google Analytics

Getting the Tracking Code

  1. From the “Admin” section of your Google Analytics account, select the “Account” and “Property” you want to add tracking to. (You may want to create a new profile to test with, so as not to dirty up your real account with test data.)
  2. In the “Tracking Info” section under “Property”, select “Tracking Code”.
  3. Complete the setup as Google Analytics instructs: “Copy and paste it into the code of every page you want to track.” Do not put this code on your FoxyCart cart, checkout, or receipt templates. If you're only using Google Analytics to track FoxyCart transactions, and aren't doing anything else custom with Google Analytics, you can skip the copy/pasting into your own site, and rely on the checkbox in the FoxyCart admin, detailed below.
  4. Proceed to the next section.

Using Google Tag Manager? Instead of using the Analytics tag that is provided by default with Google Tag Manager, create a “Custom HTML” tag, and paste into that the Tracking Code as detailed above. Also, if you include Google Tag Manager on your cart, checkout or receipt templates, ensure you don't include the Analytics tracking code on those pages - we include it for you automatically.

Configuring Your Profile Settings

  1. Edit your View Settings in your Google Analytics Settings section. (You can get here by clicking the “Admin” link in the top right, then select your “Account” and “Property” dropdowns.) Select “View Settings” under “View”
  2. Add fcsid to the “Exclude URL Query Parameters” in your analytics settings. Details here.
  3. Set your timezone and currency as desired.
  4. You may want to set your “Default Page” to index.html or index.php or etc. But make sure you understand what this means, as it affects stuff like yourdomain.com/ as well as yourdomain.com/dir/sub/. More info here and here.
  5. Click the “Save” button at the bottom.
  6. Click the “Ecommerce Settings” on the left. Enable ecommerce, but leave “Enhanced Ecommerce” off. (If you'd like to see this supported, please let us know. Click the “Submit” or “Save” button.
  7. Proceed to the next section.

Excluding Referral Sources

  1. Go back a level in the Google Analytics settings (you may need to click the left arrow on the far left edge of the screen) and click 'Tracking Info', then click 'Referral Exclusion List'.
  2. Click 'Add Referral Exclusion' and add your website's domain(s). By default, your own website's domain may be present here, but if it's not, you'll need to add it.
  3. If you're using a FoxyCart subdomain (like mystore.foxycart.com), click 'Add Referral Exclusion' and enter your store domain and click “Create”. (You can find this in the “store sub domain” value in your FoxyCart admin's “settings” page.) If you're using a custom subdomain like secure.yourstore.com, you don't need to add it there.
  4. If you're using a hosted payment option where the customer is redirected to a separate page to complete payment, you will need to add an exclusion for them as well.
Name URL
PayPal paypal.com
DIBS payment.architrade.com
iDEAL Ogone secure.ogone.com
Dwolla dwolla.com
Amazon FPS amazon.com
Bitpay bitpay.com
CyberSource Secure Acceptance cybersource.com
2Checkout 2checkout.com

Proceed to the next section

Creating Your Goals

  1. Go back up a level again (the left arrow at the far left of the screen). Under your property's “View”, click “Goals” and then “Create a goal” or “New Goal”. (Google makes changes to their Analytics interface, so the exact text might be slightly different.)
  2. Enter a “Goal Name” that makes sense to you, like “E-commerce Sale” or “Transaction” or etc.
  3. Set the “Goal Type” to “Destination” and click “Next Step”.
  4. Switch the “Destination” dropdown to “Equals To”.
  5. Enter for your Goal URL: /receipt
  6. Leave the Value switch off. (It will be calculated dynamically.)
  7. Turn on the “Funnel” switch and:
    1. Step 1: use “Cart” for the Name and /cart for the Screen/Page. (You won't have this step if you are using “direct to checkout” with the parameter “cart=checkout”). Do not check the “required step” checkbox, as there are situations where the cart can be skipped.
    2. Step 2: “Checkout” for the Screen/Page and /checkout for the URL.
  8. Hit the “Save Changes” or “Create Goal” button down at the bottom. (The receipt page is the goal, so you don't need to add it in the steps.)

Hosted Payment Method Goals

If you're using a hosted payment method like PayPal Express Checkout or Amazon, you can create additional goals to track specific conversions for those options.

PayPal Express Checkout

Name: “Sale (PayPal as Checkout)“
Destination: /receipt_paypal_ec_from_cart
Funnel:

  1. Cart, /cart
  2. PayPal (Checkout), /paypal_ec_checkout
  3. Checkout (Confirmation), /checkout

Name: “Sale (PayPal as Payment Method)”
Destination: /receipt_paypal_ec_from_checkout
Funnel:

  1. Cart, /cart
  2. Checkout, /checkout
  3. PayPal (Payment Method), /paypal_ec_payment
Amazon FPS

Name: “Sale (Amazon as Checkout)“
Destination: /receipt_amazon_mws_from_cart
Funnel:

  1. Cart, /cart
  2. Amazon FPS (Checkout), /amazon_mws_checkout
  3. Checkout (Confirmation), /checkout

Name: “Sale (Amazon as Payment Method)“
Destination: /receipt_amazon_mws_from_checkout
Funnel:

  1. Cart, /cart
  2. Checkout, /checkout
  3. Amazon FPS (Payment Method), /amazon_mws_payment
Other Hosted Gateways

If you use other hosted gateways, you can set up goals for them as well, the goal would look like this:

Name: “Sale (NAME as Payment Method)“
Destination: /receipt_CODE_from_checkout
Funnel:

  1. Cart, /cart
  2. Checkout, /checkout
  3. NAME (Payment Method), /CODE_payment

In that gateway, you'd set NAME to be the actual name of the gateway - this is for your reference within Google Analytics. You'd also change CODE to match the code for your gateway:

Name Code
PayPal paypal_ec
PayPal (deprecated) paypal
DIBS dibs
iDEAL Ogone ogone
Dwolla dwolla
Amazon amazon_mws
Amazon FPS amazon_fps
Bitpay bitpay
CyberSource Secure Acceptance cybersource_sa_web
2Checkout twocheckout

Proceed to the next section.

Enabling Google Analytics for your store

  1. Head to your store's FoxyCart administration, and to the template configuration page.
  2. Enable the 'Configure your third-party analytics' option, and enable 'Google Analytics'.
  3. Enter your Google Analytics profile tracking ID into the text field.
  4. If you want FoxyCart to include the Google tracking code on your website, and haven't included it manually yourself - check the option to include it here. This option will include the Google default tracking code within the loader.js file you include on your website. If you're manually including the Google Analytics tracking code on your website, leave this option unchecked.
  5. Save your updated configuration setting.

Have you customised your cart, checkout or receipt templates? The tracking code is added through the custom footer placeholder within the templates. If you've customised them - double check that you've included the custom code placeholders as detailed on the template customisation wiki page

Testing

First off, we strongly recommend creating a new profile in Google Analytics to test with. That way you don't have to worry about running 100 transactions and completely destroying the accuracy of the analytics, which is the entire point.

For testing, Google Analytics has a great feature called “Real-Time” which is the first option under “Standard Reports” when looking at an individual analytics profiles reports. Using this section, you can pretty quickly track whether your analytics code is correctly set up. What you'll be doing is switching between Google Analytics Real-Time Overview page and your store as you perform different actions to ensure it's tracking you correctly. If it is, you should see an individual session being tracked as you move throughout the checkout flow - changing pages as you do.

Before starting, try clearing your browser's cookies (at least for the domains in question: your site domain and FoxyCart.com) and preferably using a browser that you don't use to develop in. So if you use Firefox to administer your site through a CMS and to login to the FoxyCart admin, try testing in Chrome or Safari. The goal is to pretend you're a normal customer.

  1. Load up your website in one tab and then load up the Google Analytics Real-Time Overview in a second tab. You should see your analytics session tracking that you're looking at your website.
  2. Add a product to the cart, loading up the cart and then look back and Google Analytics. You should see it change your single user session to be on the cart.
  3. Complete a checkout, confirming after each stage that your Analytics session is tracking you as you go.
  4. After completing a checkout, switch to the 'Conversions' tab in the Real-Time section and ensure that your goal has been correctly tracked.
  5. Clear your cookies, especially any of the Google Analytics cookies, which are named _utm*.
  6. If you're using PayPal Express Checkout or Amazon FPS, try testing that a few times both from the cart and from the checkout. Go all the way through, stop before completing, bail out on the PayPal end of things, etc.
  7. If at any point you see multiple sessions in the 'Overview' page for what you're doing, double check that all of the code is inserted for the page that created a new session as detailed above.
  8. Once you've tested quite a bit go to your Google Analytics → Conversions → Goals → Funnel Visualization. It should hopefully look something like the image to the right. The key is that the numbers in between the steps are not zero. If you have values there it's tracking the user through the steps, indicating that the Google Analytics info is being passed correctly across domains. If you have zeroes in there, go back through the steps to ensure you have all the code inserted as it should be. Post on our forum if you get stuck.
  9. Party down! You're done.

Tracking Your Changes

Working with Analytics can be a big undertaking at times, and as changes to your set up isn't retroactively applied to previous statistics, can lead to some confusion in your data. We recommend setting up an analytics journal to keep track of any and all changes you make to your analytics profile and tracking code. By doing that, you can quickly compare your statistics to when you applied a certain change to make sure it's working, and possibly explain why the data is different to an earlier time period.

Using Custom Ecommerce Tracking

You can find more information on how to add a custom tracking code here: Using Custom Tracking Code

Site Tools