EverShop v2.4: CSV Import, GA4 Ecommerce Tracking and Cart Recovery
EverShop v2.4 is out. You can now import categories, products, customers and addresses from CSV files. The storefront publishes shopping events in the browser, and the built-in Google Analytics 4 sends ecommerce events with Google Consent Mode. Cart recovery links bring a saved cart back to a shopper in any browser. Every order is now marked as placed exactly once, whatever the payment method.
v2.4 also fixes several security issues, so please upgrade soon. It runs 15 database migrations and changes a few behaviours. Read Breaking changes and Upgrading before you update.
๐ฅ CSV importโ
A new import core module adds Admin โ Import. You can import four types of data: categories, products, customers and customer addresses.
Each type has a template to download. It contains the header row, two example rows, and one column for each attribute (attr:<code>) and custom field (metafield:<code>) of your store, so the template always matches your catalog.
Nothing is written until the whole file is checked. The import first checks what each row says, then checks it against your store (for example, that a category or a variant attribute exists). Every problem is listed with its row, column and message. Download file with errors gives you the same file back with an _errors column, so you can fix it in your spreadsheet and upload it again.
The import uses the same rules as the admin. Rows are saved through the same services as the admin forms. Imported records follow the same validation and fire the same events, so webhooks, search indexing and page URLs all work as usual.
What each type can do:
- Products: simple products and variant groups (
variant_group,variant_axes), images by URL, custom fields, andredirect_fromto keep old URLs working with a permanent (301) redirect. Each image is downloaded once and checked to be a real image. It is saved in your configured storage (local, S3, Azure or Google Cloud). - Customers: a bcrypt
password_hashfrom your old platform is kept as it is, so customers can sign in with their old password. A customer without a password can use "Forgot your password?". The import sends no welcome email. - Addresses are validated with the address format of each country.
The import runs in the background, in its own process, and the page shows its progress. You can cancel it, and resume it after a stop or a server restart. It also slows down when the store's event queue is long, so the storefront stays fast during a big import. In our tests, 50,000 simple products took about 10 minutes on a fast laptop.
The default limits are 100 MB and 200,000 rows per file (system.import). Messages appear in your store's language, in all 17 languages. There is also an admin REST API for automated imports.
See the CSV Import guide and the Import REST API.
๐ Shopping events and Google Analytics 4โ
The storefront now publishes commerce events in the browser. Analytics and marketing scripts can listen to them instead of reading the page:
product_viewed, product_added_to_cart, product_removed_from_cart, cart_viewed, checkout_started, checkout_contact_info_submitted, coupon_applied, coupon_removed, checkout_shipping_info_submitted, payment_info_submitted and checkout_completed.
An extension or theme listens with onCommerceEvent. For example, to send add-to-cart events to the Meta Pixel:
import { onCommerceEvent } from '@evershop/evershop/components/common/commerceEvents';
import React from 'react';
export default function MetaPixelEvents() {
React.useEffect(() => {
const stop = onCommerceEvent('product_added_to_cart', (event) => {
const { currency, value, items } = event.data;
window.fbq?.(
'track',
'AddToCart',
{
currency,
value,
content_type: 'product',
contents: items.map((item) => ({ id: item.sku, quantity: item.qty }))
},
{ eventID: event.id }
);
});
return stop;
}, []);
return null;
}
export const layout = {
areaId: 'body',
sortOrder: 50
};
A script that is not part of the store's code, such as Google Tag Manager, uses window.evershop.onCommerceEvent instead.
Events are built to keep the store fast. Listeners run in the background after the page has updated, so a slow tracking script does not slow down the shopper's next tap. A script that loads late still receives the page's last 50 events.
These events come from the browser, so do not trust their amounts for accounting. The server's order_placed event is still the record of a sale. See Commerce Events.
Google Analytics 4 (Store Setting โ Analytics) uses these events. Besides page views, it now sends view_item, add_to_cart, remove_from_cart, view_cart, begin_checkout, add_shipping_info, add_payment_info and purchase (once per order), with item categories and coupons. A new Cookie consent setting turns on Google Consent Mode: GA4 sets no cookies until the shopper accepts.
๐ Cart recoveryโ
A guest's cart belongs to their browser session, which expires after 24 hours. Until now, an abandoned-cart email could only send the shopper to the shop.
buildCartRecoveryUrl(cartId) now returns a signed link (/cart/recover/<token>) that gives the saved cart's products back to the shopper in any browser or device:
- Opening the link changes nothing, because some email security tools open every link in an email. The shopper clicks Restore my cart to get the products back.
- The products go through the cart service again, so stock and prices are checked.
- A link works once and expires after 30 days by default (
checkout.cartRecovery.ttlDays). A customer's cart needs that customer to sign in.
Two more pieces make an abandoned-cart flow possible:
- The checkout saves a guest's email to the cart as soon as it is entered.
- A new
cart_email_addedevent (also a webhook topic) tells you when a cart can be emailed.
A subscriber can build the link and pass it to your email service:
// extensions/my-abandoned-cart/src/subscribers/cart_email_added/sendStartedCheckout.ts
import { buildCartRecoveryUrl } from '@evershop/evershop/checkout/services';
import type { EventDataRegistry } from '@evershop/evershop/types/event';
export default async function sendStartedCheckout(
data: EventDataRegistry['cart_email_added']
) {
const link = buildCartRecoveryUrl(data.cart_id);
if (!link) {
return; // CART_RECOVERY_TOKEN_SECRET is not set
}
// Send data.customer_email, the cart's items and the link to your email service
}
Links need the new CART_RECOVERY_TOKEN_SECRET environment variable. See buildCartRecoveryUrl.
Abandoned payments now give the cart back too. When a shopper leaves PayPal or a Stripe 3-D Secure check without paying, the order is cancelled, the stock is restored and the cart comes back. A new Stripe job, every 15 minutes, also records payments whose webhook was lost, and cancels Stripe orders that stay unpaid for 1 hour.
โ Orders are placed exactly onceโ
A new service, markOrderPlaced, sets the new order.placed_at column and emits order_placed once per order. Cash on Delivery, Stripe, PayPal and zero-total checkouts all use it.
Before, some cases sent order_placed (and the confirmation email) twice: two PayPal finalizations running at the same time, an authorization followed by a capture, or a zero-total checkout. They now send it once.
Payment extensions should call markOrderPlaced instead of emitting order_placed themselves. When the gateway says the money will never come, they should call cancelAbandonedOrder so the shopper gets the cart back. See markOrderPlaced and Payment Method Development.
๐งฉ For extension developersโ
- Sign in without a password, for social logins and headless storefronts:
request.loginCustomer,getCustomerByEmailandissueCustomerTokens. They create the same session and tokens as the password login. See request.loginCustomer. - URL helpers:
getProductUrlandgetProductUrlsreturn a product's storefront URL, andgetAssetUrlandgetImageUrlreturn the full URL of a stored file or a resized image, for every storage provider.buildUrlnow also works in subscribers and cron jobs. See getProductUrl. - New events:
product_back_in_stock(also a webhook topic) fires whenever a product goes from out of stock to in stock.inventory_updatedfires only when the stock really changes. - Real update times:
updated_atis now refreshed on every update of 19 core tables, so webhooks, GraphQL and the sitemap show when a record really changed. UseaddUpdatedAtTriggerto add the same behaviour to your own tables. - More services: permanent (301) redirects,
createCustomeroptions for imports (passwordHash,allowNoPassword,suppressRegistrationEvent),createVariantGroup,addVariantItem, andimportOrderfor orders that already happened. - Database timeouts per process:
DB_LOCK_TIMEOUT_MSandDB_STATEMENT_TIMEOUT_MS.
๐ Securityโ
Please upgrade soon. This release fixes:
- Sign-in forms could put the password in the URL (GHSA-cfwv-hv27-hfhp). A form submitted before the page's JavaScript loaded was sent as a GET request, so the email and password could end up in the browser history and server logs. Forms now always post.
- Public sign-up could set store-only fields. An anonymous visitor could choose their customer group (with its prices and promotions) and their account status. The sign-up response also returned the password hash.
- Signing out handed the cart to the next person on the same browser, including the previous customer's billing name, phone and address at checkout.
- Customer events carried the password hash to every subscriber.
- The SSRF (server-side request forgery) guard now refuses more forms of private addresses in webhook URLs and import image URLs.
๐ ๏ธ Other changes for store ownersโ
- Unpaid Stripe orders are cancelled after 1 hour and the stock is restored. You can change the delay or turn the job off (see Upgrading).
- No cancellation email for an order that was never placed, such as a PayPal payment the shopper left. The admin still sees the cancellation.
- Footer: while you have not set your own copyright text, the footer shows "Powered by EverShop" after the copyright line. The card icons were removed from the storefront footer.
- "Allow guest checkout" moved to Settings โ Customer โ Checkout. Your saved value is kept.
- Customer emails match in any letter case for forgot password, sign-up and profile update, as login already did.
๐ Bug fixesโ
Some of the fixes in this release:
- Partial updates from the REST API, scripts and extensions no longer reset the fields they leave out (#1103). For example, a product's description and category, or a category's parent.
- Changing only a product's URL key, name or stock now updates its URL. Before, the new URL returned 404.
- Checkout: a saved billing address shows correctly after a reload, and the payment forms are no longer covered by the "Continue to payment" button (#1175).
- The mini cart shows the new contents right after adding an item.
- Cron jobs see settings saved after the server started, for example new PayPal credentials.
- An order item's product link goes to the store page, not to the admin edit page.
See the full changelog for the complete list.
Breaking changesโ
| Change | What to do |
|---|---|
order_placed payload. Every order_placed payload is now the committed order row, with placed_at. The Cash on Delivery payload no longer has insertId. | Update subscribers that read insertId. An extension that emits order_placed itself still works, but its orders keep placed_at empty: call markOrderPlaced instead. |
OrderItem.productUrl now returns the product's store page in both GraphQL schemas. It used to return the admin edit page. | If you used it as an admin link, use buildUrl('productEdit', { id }) instead. |
A few smaller changes may affect integrations:
- The 11 public cart routes with
:cart_idin their path answer 404 for an unknown cart, instead of 500. POST /api/customersandPATCH /api/customers/meignore store-only fields such asgroup_idandstatus.updateProduct,updateCategory,updateCoupon,updatePageand the REST update routes write only the fields they receive.evershop seedno longer forcesNODE_ENV=development.
Upgradingโ
npm install @evershop/evershop@2.4.0
npm run build
npm run start
Or with Docker:
docker pull evershop/evershop:2.4.0
This release runs 15 database migrations. Most add or replace triggers. One adds order.placed_at and fills it for existing orders, and two add new tables for the import and Stripe. They run automatically on the first start.
evershop build fails on Node.js 20.9 and 20.10. Earlier release notes said 20.9, but v2.2.2 and v2.3.0 have the same limit. Node.js 20 has reached its end of life, so we recommend Node.js 22 or newer.
After upgrading:
- Stripe: unpaid Stripe orders are now cancelled after 1 hour. Change the delay with
system.stripe.abandonedOrderTtlHours, or turn the job off withsystem.stripe.reconcileEnabled: false. - Cart recovery links: set
CART_RECOVERY_TOKEN_SECRETto a long random string. Without it, nothing else changes. Changing it later cancels every link already sent. - GA4 and a cookie banner: upgraded stores start with Cookie consent set to Not required. If you use GA4 with a cookie banner, choose Required in Store Setting โ Analytics. Otherwise GA4 sets cookies before the shopper accepts.
- CSV import runs in a worker started by the event process. If your deployment does not run the event process, you cannot import.
- Themes: a theme that overrides
Footershows no "Powered by EverShop" unless it rendersPoweredByEverShop.
How we tested this releaseโ
Before publishing v2.4, we ran a new release check on the packed package:
- A fresh install, and upgrades from v2.3.0 and v2.2.2 with real orders, customers and products made by the old version.
- Catalog, customer accounts, checkout with and without a coupon, and admin order handling (capture, refund, ship, cancel), including the emails they send.
- Stripe in test mode (including 3-D Secure, a declined card, and authorize, capture and refund) and PayPal in the sandbox.
We ran the same check again on the package published to npm. We will run it before every release from now on.
Thanksโ
Thanks to everyone who contributed to this release and to those who reported the issues it fixes. If you hit a problem while upgrading, open an issue or ask on Discord.
