LogoLogo
Build appsContact API support
Storefronts
  • Build apps
  • Site Templates
  • API Reference
  • Changelog
Storefronts
  • Ecwid storefronts overview
  • Get started
    • Storefront customization options
    • Quickstart: customize storefront with Ecwid JS API
  • Track Storefront events
    • "Page is loaded" events
    • "Customer logged in" event
    • "Cart details are changed" event
    • "New order is placed" event
    • "Instant Site section load" events
  • Get Storefront details
    • Get Ecwid store ID
    • Get storefront language and currency
    • Get visitor location
    • Get public app details
  • Manage customers on the storefront
    • Get logged in customer's details
    • Manage customer's cookie consent
    • Log out customer
  • Open page on the storefront
    • Overview of open page options
    • Open product pages with params
    • Open category pages with params
    • Open search page with params
    • Open account pages with params
  • Manage cart and checkout
    • Get cart details
    • Add product to the cart
    • Remove product from the cart
    • Fully clear the cart
    • Create pre-filled shopping carts
    • Calculate cart details
    • Send customer to the checkout
    • Set customer's email for the checkout
    • Set customer's comments for order
    • Set customer's shipping and billing addresses
    • Set custom order referer
  • Store configuration settings
    • Overview
    • Behavioral configs
    • Design configs

Lightspeed® 2025

On this page
  • Get user's cookie consent
  • Set user's cookie consent
  • Track changes in consent value
  • Enable cookie-free mode on the website

Was this helpful?

  1. Manage customers on the storefront

Manage customer's cookie consent

Storefront JS API allows you to set cookie consent on behalf of the user or react to its changes depending on the value.

Find a list of available methods below.

Get user's cookie consent

The Ecwid.getTrackingConsent(); receives the customer's answer to the cookie consent banner. Use it to define what cookies your application can collect.

If the cookie consent value is overridden by the JS method or config, Ecwid.getTrackingConsent() returns the new value added by JS method/config.

Code example:

Ecwid.getTrackingConsent();

// {  userResponse: "ACCEPTED", askConsent: true }

Fields available in the returned object:

Field
Type
Description

userResponse

string

Customer's cookie consent. Available values:

  • "UNDEFINED": Customer hasn't given their consent yet.

  • "ACCEPTED": Collect all types of cookies.

  • "DECLINED": Collect only essential cookies.

  • "ANALYTICS_ONLY": Collect essential and analytics cookies only.

  • "PERSONALIZATION_ONLY": Collect essential and personalization cookies.

askConsent

boolean

true if store requests customer consent, false otherwise.

Set user's cookie consent

There are two ways of setting cookie consent value on behalf of the user: through the JS function and the HTML code. We recommend using only one of these methods on your website. If both are used, the HTML config gets higher priority.

The JavaScript method is useful when you add Ecwid to a website that asks for users' cookie consent before Ecwid. With it, you can dynamically set cookie consent for the Ecwid store, when users set it on your website.

The HTML config allows you to disable the cookie consent banner and set one value on behalf of users. For example, you can use it to only allow analytics cookies for all users.

Set cookie consent with JavaScript

The Ecwid.setTrackingConsent(); method accepts an argument matching one of the following values:

  • "UNDEFINED": Customer hasn't given their consent yet.

  • "ACCEPTED": Collect all types of cookies.

  • "DECLINED": Collect only essential cookies.

  • "ANALYTICS_ONLY": Collect essential and analytics cookies only.

  • "PERSONALIZATION_ONLY": Collect essential and personalization cookies.

Code example:

Ecwid.setTrackingConsent("DECLINED");
Ecwid.getTrackingConsent();
//{userResponse: "DECLINED", askConsent: false}

Set cookie consent with HTML

The ec.config.tracking.ask_consent config must always be true.

Value of the ec.config.tracking.user_response defines the consent and must be one of the following:

  • "UNDEFINED": Customer hasn't given their consent yet.

  • "ACCEPTED": Collect all types of cookies.

  • "DECLINED": Collect only essential cookies.

  • "ANALYTICS_ONLY": Collect essential and analytics cookies only.

  • "PERSONALIZATION_ONLY": Collect essential and personalization cookies.

Code example:

<script>
ec.config = ec.config || {};
ec.config.tracking = ec.config.tracking || {};
ec.config.tracking.ask_consent = true;
ec.config.tracking.user_response = "DECLINED";
</script>

Track changes in consent value

The Ecwid.OnConsentChanged(); method allows you to catch any changes to the consent value.

Code example:

Ecwid.OnConsentChanged.add(function(consent) {
    console.log("consent changed to " + consent);
});
Ecwid.setTrackingConsent("DECLINE");
//consent changed to DECLINED

Enable cookie-free mode on the website

Code example:

<script>
window.ec = window.ec || Object();
window.ec.config = window.ec.config || Object();
window.ec.config.disable_all_cookies = true;
</script>

Last updated 2 months ago

Was this helpful?

Before using this JavaScript method, make sure to in your script file.

You can override the user's cookie consent with a static value through the . You need to add a <script></script> block right under the integration code with four config lines inside. All config lines are required.

You can disable the collection of all non-essential cookies completely by adding a specific config to the .

enable JS API
Ecwid HTML integration code
Ecwid HTML integration code