Abandoned carts & Viskan setup

Code F CRM keeps track of each shopper's cart from your website's GA4 events. When a known contact leaves a cart, it puts one cart.abandoned event on the contact, which can start a reminder email or SMS. It does the same for checkouts that never became an order, and for products someone looked at but didn't buy.

This page covers how carts are followed, the events and their fields, and the setup on Viskan Streamline. Start with Website tracking & GTM if the tracker isn't on your site yet.

How carts are followed

The tracker forwards the shop's GA4 cart events. For each cart the CRM keeps the latest items (id, name, quantity, price, image and product page), the value and currency, the last activity and who the cart belongs to.

What happens on the siteWhat the CRM does
cart_update or view_cart with the full cartReplaces the cart's items
add_to_cart / remove_from_cartAdds or removes those items, when no full-cart event covers the moment
begin_checkoutMarks the cart as in checkout
purchase (or ga4_purchase) with the cart idCloses the cart as bought
purchase without a cart idCloses the visitor's open carts
The last item is removedCloses the cart quietly, without any event

A cart is known by the shop's cart id: shopcart_id next to ecommerce, ecommerce.shopcart_id, or cart_id. A shop that sends no cart id gets one cart per visitor. An item's id is the PLU when the shop sends one (item_identifier or priceLookupUnitNumber), otherwise item_id. Images come from image_url or media, product pages from item_url.

Only carts of identified visitors become events. An anonymous visitor's cart is kept, and becomes the contact's cart if they log in or arrive from one of your CRM emails before it goes quiet.

The events

EventWhen
cart.abandonedA known contact's cart, with items in it, has had no activity for the set time (4 hours by default). Once per cart.
checkout.abandonedThe contact started checkout and no purchase closed the cart within the same time. Once per cart.
product.viewed_not_bought24 hours after a contact last viewed a product they didn't add to a cart or buy. At most one per contact per 7 days, for the product they viewed most.

A cart that reaches checkout gets both cart.abandoned and checkout.abandoned. Start one automation from the event that fits your shop, not both, or the shopper gets two reminders.

Fields on cart.abandoned and checkout.abandoned

FieldType
cart_idtextThe shop's cart id
value, currencynumber, textThe cart's value
item_countnumberItems in the cart, counting quantities
itemsjsonEach item: name, id, quantity, price, image_url, product_url
first_item_name, first_item_idtextThe first item, for simple emails
first_item_image_url, first_item_urlurlIts image and product page
cart_urlurlYour cart page (see Settings), else the shop's front page

When an item arrives without an image or product page, the CRM fills them in from your synced product catalogue: the product whose SKU is the item's id, else the one with that product number.

Fields on product.viewed_not_bought

product_id, product_name, image_url, product_url and view_count (how many times the contact viewed it).

Settings

Under Settings → Website tracking → Abandoned carts:

  • Cart abandoned after: from 1 to 72 hours, 4 by default. Checkouts use the same time.
  • Your cart page: the address of your shop's cart, for example https://shop.example.com/cart. Reminder emails link there as cart_url.

There is no link that restores a cart on another device. Reminders link to the products and to the cart page, where a shopper on the same browser finds their cart as they left it.

A reminder email

Start an automation on cart.abandoned (the marketplace listing Abandoned cart recovery installs one, with an email). The event's fields are merge tags:

TEXT
{{event.first_item_name}} Blue hoodie
{{event.first_item_image_url}} https://cdn.example.com/blue-hoodie.jpg
{{event.first_item_url}} https://shop.example.com/p/blue-hoodie
{{event.cart_url}} https://shop.example.com/cart
{{event.value}} {{event.currency}}

Connect Viskan

The Viskan integration brings your shop's customers, orders, shipments and products into the CRM, and keeps them in step. It reads through an API client you create in Viskan Backoffice, and only needs to read.

  1. In Viskan Backoffice, open Developer → API clients and press Create API client. Only administrators see the page.

  2. Switch on Read, and only Read, for:

    BackofficeScope
    Customer service → Customer → Readcustomer:read
    Order management → Order → Readorder:read
    Order management → Shipment → Readshipment:read
    Product → Product → Readproduct:read
    Product → Product category → Readproductcategory:read

    Options under More settings in the CRM need more: subscriptions need Customer service → Subscription → Read (subscription:read), returns need Order management → Return → Read and Configuration → Return reason → Read (return:read, returnreason:read), and images need Configuration → Media → Read (media:read). To pick the brand from a list, add Web → Multibrand → Read (multibrand:read).

  3. Check the Scope identifiers box in Viskan's dialog against the list the CRM shows, then save the client. Viskan shows the secret only once.

  4. In the CRM, open Settings → Integrations → Connect on the Viskan card, paste the client id and secret, and press Test connection.

If the test says scopes are missing, it names them with their Backoffice switches: turn them on for the same API client and test again. Viskan refuses a client that asks for any scope it doesn't have, so the whole test fails until every one listed is on.

After you connect, the first sync starts. It reads your history without starting automations, and the card shows how far it has come per data type. Then changes come in every few minutes.

Set up on Viskan

Viskan's shop system comes in two versions, Streamline 4 and Streamline 3, and the setup differs between them. Follow the steps for the version your shop runs; if you aren't sure which one that is, Viskan support can tell you. On both, website tracking goes through Google Tag Manager: the CRM's tag reads the events the storefront already sends, so there is nothing to change in the shop's own code.

When it's done, open your shop in a browser, accept statistics and marketing cookies and put something in the cart. Settings → Website tracking lists the events as they arrive. To check the whole cart reminder, see Test it below.

Streamline 4

  1. Google Tag Manager. Create a GTM container if you don't have one, import the Code F CRM tag template and add the tag as described in Website tracking & GTM.
  2. Content Security Policy (Streamline 4). In Backoffice, go to Settings → Security → CSP directives and add https://crm.codefab.dev to script-src, connect-src and img-src. Without it the browser blocks the tracker.
  3. The GTM container id (Streamline 4). In Content management, open your store, then Store settings → Tracking. On the Google card, enter your container id (GTM-XXXXXXX) in Google Tag Manager ID.
  4. The buyer's email on the purchase (recommended). On the same Store settings → Tracking page, open Enhanced Conversions and tick Email address. The purchase event then carries the buyer's email as GA4 user_data.email, so the CRM knows who bought at once, even when they checked out as a guest. The email goes to the tags in your GTM container, so check that only tags you trust read it. The CRM uses it only to find the contact and never stores it with the event.
  5. Viskan's own cart reminder. When your Code F reminder goes live, turn off Viskan's abandoned-cart reminder in Backoffice under Configuration → Remarketing: disable the abandoned shopping cart scenario, so shoppers get one reminder, not two.

Streamline 4 already pushes what the CRM needs: shopcart_id on the cart events, a full-cart cart_update after every change, virtualPageView on each page and the purchase number as transaction_id. The PLU is the item id. Without the email from step 4, the CRM still finds the buyer once the order comes in through the Viskan connection, by the purchase number.

The purchase event comes from the Receipt component on the order confirmation page, so keep that component on the page. It is pushed once per order, only when the confirmation is shown in the same session or within 2 hours of the order, and only for an order with at least one row.

Add the tracker through GTM as in step 1, not with the page builder's HTML embed block: the tracker can't run from there.

Streamline 3

  1. Google Tag Manager. Create a GTM container if you don't have one, import the Code F CRM tag template and add the tag as described in Website tracking & GTM. This step is the same as on Streamline 4.
  2. The GTM container id (Streamline 3). In the CMS, open Site → Settings, go to the Google tab and enter your container id (GTM-XXXXXXX) in Google Tag Manager ID. Save, then Site → Publish; the id takes effect after publishing and reloading the page. The setting is per language: it applies to the market and language selected in the CMS, so repeat this for each language your shop has.
  3. Content Security Policy (Streamline 3). Streamline 3 normally needs no CSP change. If your site uses a Content Security Policy of its own, add https://crm.codefab.dev to it (script-src, connect-src and img-src).
  4. Viskan's own cart reminder. When your Code F reminder goes live, turn off Viskan's abandoned-cart reminder in Backoffice under Configuration → Remarketing: disable the abandoned shopping cart scenario. This is the same on Streamline 4 and 3. Don't confuse it with Enable remarketing under Site → Settings → Store in the Streamline 3 CMS: that setting only decides how the storefront remembers a visitor's email, and doesn't stop the reminder emails.

Streamline 3 sends ga4_purchase for a purchase, the cart id inside ecommerce, and view_cart with the full cart after every change. The CRM reads these as they are. Streamline 3 doesn't send a page view per page, so pages a visitor opens without a product or cart event don't show up.

Nothing is stored or sent before the visitor has answered your cookie banner. Events from before the answer wait in the browser and are sent only if the visitor allows statistics cookies. Tying events to a person, and so every cart event above, also needs marketing consent: without it the visitor's events stay anonymous raw hits. See Website tracking & GTM for how the tag reads the answer.

Test it

  1. Set Cart abandoned after to 1 hour.
  2. Open your shop in a private window, accept cookies, log in (or open a link from a CRM test email), put something in the cart and close the window.
  3. After an hour, the contact's timeline shows Cart abandoned with the items.