Cart view in V2

I am adding some trackers to our site (ocean addict)
and it seems the new slide-in cart is injected into the page as opposed to an iFrame.
Is that correct?

If I use the injected script option within the FC admin,
can I check for a cart page?
I have a feeling, not so since the url won't be ../cart

I would want to track it from a click trigger?
Tagged:
Comments
  • fc_adamfc_adam FoxyCart Team
    @richtestani,

    That's right - the Sidecart is injected into the page. There are definitely still ways to track things though. Could you clarify what tracker you're adding, what options it gives you for tracking events and what specific events you're wanting to track?
  • Im using the Facebook tracker - so at the moment, my script is this:

    page = location.href;

    //checkout page
    if (page.match('checkout')) {
    fbq('track', 'InitiateCheckout');
    }

    //cart page
    if (page.match('cart')) {
    fbq('track', 'AddToCart');
    }

    //receipt
    if (page.match('receipt')) {
    fbq('track', 'Purchase', {value: '1.00', currency: 'USD'});
    }
  • fc_romanfc_roman Member, FoxyCart Team
    edited June 2016
    @richtestani,

    In the custom footer, where your code resides, you can make use of Twig to check conditions and fire events depending on the check results.

    For example, an event "Checkout view" would fire on the checkout view, etc:
    <script>
    {# On cart view: #}
    {% if context == 'cart' %}
    fbq('track', 'AddToCart');
    {% endif %}
    {# On checkout view: #}
    {% if context == 'checkout' %}
    fbq('track', 'InitiateCheckout');
    {% endif %}
    {# On first-time receipt view: #}
    {% if first_receipt_display %}
    fbq('track', 'Purchase', {value: '{{ total_order }}', currency: 'USD'});
    {% endif %}

    </script>
    As usual, make sure to test every change you make to the cart and let us know if anything works differently from what you expected.
Sign In or Register to comment.