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 for "3rd party carts" (ie. (was "playing with google")

sheeleysheeley Member
in Bugs & Feature Requests edited February 2008
I just added the new(er/est?) google analytics to the site. Their step 2 (
makes FC links go to a new page instead of in a lightbox. This doesn't seem to happen with the forms, however. What should/can I do?
  • brettbrett FoxyCart Team
    We're actually playing around with this currently. The easiest solution is to use a custom subdomain, which will allow you to avoid rewriting the links and form posts. I'm still working on tracking with the custom subdomain, but will focus on a "3rd party" type situation (which is the default FoxyCart behavior, clearly) once I'm done.

    I thought you were using ClickTracks?
  • ...yeah. We are using both. mumble mumble.
  • brettbrett FoxyCart Team
    How does ClickTracks handle the cross domain cookie problems?

    I wish GA had an "unobtrusive" method to do their cross-domain linking/posting. Other than that, we're playing around with it. The trick is that the GA function hijacks the onclick that thickbox is relying on. We'll update this thread with info.
  • It seems to just work (aka I haven't looked at it in a while and don't recall). I'm not the one checking any of the data, I just implement the code side of things, so I'm assuming it's working. It uses the same code on our site as it does on the FC templates, from what I recall, with none of this onclick or onsubmit nonsense. :)
  • Brett,

    Any update on the working with Google Analytics?

  • Oh! I wondered what the heck was going on. I'm guessing that's my problem too.

    Any news on this front. It really made the cart sexy with the thickbox....
  • Brett,

    Have the same issue here. Do we have a solution to the problem or can you point me in the direction of setting up a custom subdomain with Foxycart?

  • For those who get lost, go here to get a custom subdomain:
  • Looks like it's time to bump this topic again...

    I followed the instructs at:

    and I'm not seeing any hits to cart or checkout in my analytics reports. Does anyone have this working (using a domain)?
  • lukeluke FoxyCart Team
    Thanks for the bump, Scott. We'll follow up on this one.
  • brettbrett FoxyCart Team
    edited June 2008
    Ok, after digging through the guts of ga.js, I've made some fun progress. Good news and bad.

    - I think I got it working for links. If you're interested in testing, whisper me and I'll get you the info.

    - We have a little glitch so the cart isn't ignoring product attributes that start with __, even though we should be. We'll fix this.
    - It relies on a (currently) undocumented Google Analytics internal function (_getLinkerUrl() ). Prior to April (when ga.js was v3.0), this function was named something else (.yb and .sb). In April ga.js became v4.1 (and is now v4.2), and they changed this. So... it works, and it should work, and if it stops working it should be an easy fix, but it might stop working unless Google decides to actually document the getLinkerUrl() function (which they might, as it's exceedingly handy).
    - We're not going to be able to make it work for forms unless we:
    a) change foxycart_includes.js on our end, system-wide;
    b) have you change it on your end; or
    c) wait for the next version.

    The issue is in how we're serializing form data in foxycart_includes.js. It's fixable, but we really really really don't like changing existing versions unless it's a critical security issue. If we change it and it breaks existing stores, that sucks. But it's definitely able to be worked around, so we should offer support in our next version (assuming my work tonight actually functions as expected; there's a delay with GA reporting so I can't tell yet).

    We need willing beta testers, so if you're able to play around with this, please let me know.
  • I can help with beta. Not much to lose - I'm not currently getting any stats for * hits anyway.

    Slight wrinkle - I'm traveling this week. I can implement code next week if you want me to give something a whirl.
  • ...oh, yeah: "thanks!"
  • Need any more beta testers for the Google Analytics in Foxy? I'll help...
  • lukeluke FoxyCart Team
    We've been talking more about this the last few days and we'll probably let a few select people check out the 0.4.0 release in an alpha testing phase. We still need to redo a few payment gateways to fit into the new framework along with some other changes we'd like to include in this release. We'll keep a list of interested parties and get back to you once we have something available for the public.

    Also, the values sent to the cart starting with "__" are now fixed in 0.3.2.
  • Hey Guys!

    Any chance in getting the wiki updated with instructions (in laymen's terms) on how to add the Google Analytics code when using a * subdomain?

  • brettbrett FoxyCart Team
    Thanks for the reminder. I have it about 80-90% there, so I'll finish it up and put it on the wiki for everybody to test out. If I don't update this thread by Monday give me another gentle nudge ;)
  • lukeluke FoxyCart Team
    Or just straight up beat him over the head with a lead pipe. That works too.



    I love that we make building software fun.
  • brettbrett FoxyCart Team
    edited September 2008
    I really, really hate testing Google Analytics for stuff like this, because you have to wait hours and hours to see if what you're doing is actually showing up. Cross-domain tracking and 3rd party cookies are difficult to work with (or without).

    An update, in case anybody cares:
    - I have it working with links and with 3rd party cookies enabled in the browser.
    - We'll see if we can make it work with forms with the 040 code.
    - ga.js isn't behaving inside the iframe, which creates problems when 3rd party cookies are disabled.

    I'll be digging in a little deeper, but that third point is really frustrating me. the (still undocumented) _pageTracker._getLinkerUrl() function isn't working inside the Thickbox iframe. If anybody has any ideas please let me know. It's tricky because we're not only doing cross-domain stuff, but also frames, which is kind of a double whammy for almost everything we're trying to accomplish.

    I'm going to come back to this once we have 040 out the door, as we'll be tweaking some stuff that will help, and we're really close. I'll update this thread when I'm able to come back to it.
  • Bumping. We're not in a rush, but it would be great to see this by the end of the year. Plus really really clear instructions. :)
  • brettbrett FoxyCart Team
    Still trying to get this working when 3rd party cookies are disabled. My thoughts at present:

    - If 3rd party cookies disabled isn't able to be worked around, the solution is to track the add-to-cart _click_, not the cart load. This would actually probably be easier, and would work for JSON add-to-cart links, and for forms, and etc.
    - We need to make sure that the GA session info gets passed from the cart to the checkout. I've put together a quick little way to make this happen.

    I'm thinking that the best way to make this happen would be to track the add-to-cart link/form click rather than the cart pageload, since I'm having a really difficult time getting that to run when 3rd party cookies are disabled. There's not much discussion about how exactly javascript is limited when running in a cross-domain iframe, which makes it even trickier.

    The question, I suppose, is this: Does anybody have any concerns or questions about tracking based on add-to-cart link/form click as opposed to cart load? As far as I can think it through it shouldn't really make a difference, but I've only ever worked on this issue super late at night so I might be missing something.

    This method would _not_ track the cart page load, so it wouldn't track if the customer updated their cart. Does that destroy anybody's data collection goals?

    If anybody wants to test, I've put together instructions for the "track on click" method as discussed above:
    It's close to 3am so there are no guarantees that this will work, but it seems to at least be firing off the correct GA calls as far as I can tell. I would strongly recommend testing this on a TEST store, not on a live store, as there is the very real possibility that this breaks things at this point. That said, we'd love help testing this!
  • brettbrett FoxyCart Team
    Oh, oops, I must have left some testing code in there. I'll update that in a little bit.
  • brettbrett FoxyCart Team
    Ok, fixed. Just some testing code left in there.
    Give that a go and let me know if it works for you. There may need to be tweaks, but I think it should work properly at this point.
  • At first glance, looks good. Waiting for data to show up in Analytics (lag) but looks promising! thanks!
  • So the cart is being tracked successfully (yay!) but right now the thickbox pops up correctly, then redirects to the php page. Any ideas on how to keep the thickbox in place and working? thank you!!
  • brettbrett FoxyCart Team
    I'm not positive I follow, but I took a quick look at your code and I see you have an onclick event on your actual a.foxycart element, which might be causing problems. Remove that and see if it gets you what you want.
  • does this solution allow us to fully use analytic's e-commerce tracking?

    also, this interesting link from the analytics blog today:
  • brettbrett FoxyCart Team
    Yes, full ecommerce tracking in all it's wonderful glory.

    Event tracking is interesting, but I think that for what we're doing here it isn't the right choice. I haven't played with events much yet (since I just got access to them today ;), but I'm not sure you can set an event as part of a funnel. You should be able to use the method outlined on this thread and the wiki to track events as well, but a tracking it as a pageload makes more sense to me.

    What might make sense for events would be cart _actions_, like changing a quantity or removing an item. Also potentially interesting would be tracking events on the checkout itself, like track the event of the user entering an email, hitting the checkout button or logging an error, stuff like that. That could be really interesting, as it'd get you some info on the customer's behavior within the goal funnel and checkout process.
  • Thank you so very much for the wiki on this - it worked like a champ and I'm tracking "glorious" stats in a dev account. I did notice one thing, and was wondering if anyone had thoughts / workaround / solution: If I purchase the same product, multiple times, in one transaction; where each instance has a different product option, google only tracks one line item. And it's throwing off the stats. Below's an actual example of the javascript written to the receipt page for google, where only the first of the "flights" was tracked, yet the total transaction amount shows up in google. The first chunk is the fc_json object, the second chunk was for google. Any ideas would be sweet, and thanks again for all the solid work.

    fc_json = {
    "id": "285482",
    "name": "Custom Flight Offset",
    "code": "flight_offset_calculated",
    "options": {"flight path":"Denver, Colorado <-> San Antonio, Texas","co2":"690","miles":"1628"},
    "quantity": 1,
    "price_each": 4.8,
    "price": 4.8,
    "weight_each": 0,
    "weight": 0,
    "shipto": "",
    "category": "gift"
    "id": "285483",
    "name": "Custom Flight Offset",
    "code": "flight_offset_calculated",
    "options": {"flight path":"Bogota, Colombia <-> San Jose, Costa Rica","co2":"662","miles":"1563"},
    "quantity": 1,
    "price_each": 4.65,
    "price": 4.65,
    "weight_each": 0,
    "weight": 0,
    "shipto": "",
    "category": "gift"
    "product_count": 2,
    "total_price": 9.45,
    "total_weight": 0,
    "session_id": "o57ldp3e8cusm3je1s8ks14rk3",

    "177347", // Order ID
    "DEV SITE", // Affiliation
    "9.45", // Total
    "0", // Tax
    "0", // Shipping
    "loveland", // City
    "CO", // State
    "US" // Country

    "177347", // Order ID
    "flight_offset_calculated", // SKU
    "Custom Flight Offset", // Product Name
    "gift", // Category
    "4.8", // Price
    "1" // Quantity

    "177347", // Order ID
    "flight_offset_calculated", // SKU
    "Custom Flight Offset", // Product Name
    "gift", // Category
    "4.65", // Price
    "1" // Quantity

  • lukeluke FoxyCart Team
    Thanks for the compliments bret_ortan.

    Maybe you could add values to your product code (sku) so that google will track them as unique values? I'm not really sure what else we can do to get around this as it sounds like a limitation with how google's analytics works.

    I don't see anything on there we could use to pass in more details...
Sign In or Register to comment.