Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@ekolabs/eko-gallery-react

Package Overview
Dependencies
Maintainers
2
Versions
1679
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ekolabs/eko-gallery-react

eko gallery for react framework

latest
npmnpm
Version
3.0.35
Version published
Weekly downloads
5.4K
29.74%
Maintainers
2
Weekly downloads
 
Created
Source

A library for integrating the eko gallery into your react based site.

Installation

npm install @ekolabs/eko-gallery-react

OR

yarn add @ekolabs/eko-gallery-react

Usage

EkoGallery Component

The EkoGallery component is used to render the eko gallery on your site. It should replace your existing product gallery component.

import { EkoGallery } from '@ekolabs/eko-gallery-react';

<EkoGallery 
    className="mb-4"
    config={config}
    variantId={variantId}
    activeItemIndex={activeItemIndex}
    onEvent={onEkoGalleryEvent}
>
    {/* Your existing product gallery component that will serve as a fallback */}
    <CustomerGalley />
</EkoGallery>

This component accepts the following props:

PropTypeDescription
classNameStringOptional. class names to add to the EkoGallery component, for styling purposes for example.
configObjectThe eko gallery configuration. This object will be published via the eko platform and exposed via an api endpoint (see below).
variantIdStringOptional. The selected variant (if applicable). It is used to switch to the relevant variant gallery assets when the product variant changes.
activeItemIndexNumberOptional. Updates the displayed item of the EkoGallery.
onEventFunctionOptional. Handler for events occurred in the eko gallery, for third party tools tracking for example.

When passing the onEvent prop, make sure to use the useCallback() hook to avoid unnecessary re-renders.

Config data fetching

To get the eko product configs, you should use the getEkoProductConfigUrl() function to get the url, fetch the data and pass it to the EkoGallery component.

The getEkoProductConfigUrl() receives the eko sales channel id and returns the url to fetch the eko product configs from.

import { getEkoProductConfigUrl } from '@ekolabs/eko-gallery-react';

const EKO_SALES_CHANNEL_ID = process.env.EKO_SALES_CHANNEL_ID;

const ekoProductConfigUrl = getEkoProductConfigUrl(EKO_SALES_CHANNEL_ID);
const ekoProductResponse = await fetch(ekoProductConfigUrl).then(res => res.json());
const ekoProductConfigs = ekoProductResponse.data;

Analytics setup

Our 1st party tracking tool should be added in order to track events on the site.

The eko analytics snippet

The eko analytics snippet should be added to the site's head tag, here is an example in Next.js:

// _document.tsx

import Script from 'next/script';
import { getEkoAnalyticsSnippet } from '@ekolabs/eko-gallery-react';

const IS_PRODUCTION = process.env.NODE_ENV === 'production';

render() {
    return (
        <Html lang="en">
            <Head>
                <Script id="eko-analytics-snippet" strategy="beforeInteractive">
                    {getEkoAnalyticsSnippet(IS_PRODUCTION)}
                </Script>
            </Head>
            <body>
                <Main />
                <NextScript />
            </body>
        </Html>
    );
}

Events

The eko gallery dispatches events through the onEvent handler. Use this to track user interactions and gallery lifecycle events.

Event Types

EventDescription
galleryinitFired when the gallery component initializes
gallerycoverdisplayedFired when the cover image (first carousel item) loads
galleryloadedFired when the interactive smart gallery is fully loaded
activeitemindexchangedFired when the active gallery item changes
interactionFired on user interactions (clicks, scrolls, buttons, etc.)
swipeFired when the user swipes within the interactive video

Event Payloads

activeitemindexchanged event

Fired when the displayed gallery item changes (via thumbnail click, carousel scroll, or internal navigation).

PropertyTypeDescription
indexNumberThe zero-based index of the newly active item
interaction event
PropertyTypeDescription
elementidStringA unique identifier of the element that was interacted with
interactiontypeStringThe type of interaction (click, wheel, swipe)
elementtypeStringThe type of element (e.g., start, next button, choice button)
elementnameStringA textual representation of the element

Common elementid values from the gallery:

  • thumbnail-{index} - Thumbnail navigation item clicked
  • nav - Navigation strip scrolled
  • carousel - Main carousel scrolled
  • eko-nav-arrow-prev / eko-nav-arrow-next - Navigation arrows clicked
swipe event

Fired when the user swipes within the interactive video.

Lifecycle events (galleryinit, gallerycoverdisplayed, galleryloaded)

These events are fired without a payload and indicate gallery state transitions.

Example

const onEkoGalleryEvent = useCallback((event, data) => {
    switch (event) {
        case 'galleryinit':
            console.log('Gallery initialized');
            break;
        case 'gallerycoverdisplayed':
            console.log('Cover image loaded');
            break;
        case 'galleryloaded':
            console.log('Interactive gallery ready');
            break;
        case 'activeitemindexchanged':
            console.log(`Active item changed to index: ${data.index}`);
            break;
        case 'interaction':
            console.log(`Interaction: ${data.elementid} (${data.interactiontype})`);
            break;
        case 'swipe':
            console.log('User swiped in interactive video', data);
            break;
    }
}, []);

ekoWebPixel

The ekoWebPixel API is used to track the events on your site.

Init once via the init() method:

import { ekoWebPixel } from '@ekolabs/eko-gallery-react';

const IS_PRODUCTION = process.env.NODE_ENV === 'production';

useEffect(() => {
    ekoWebPixel.init(IS_PRODUCTION);
}, []);

Track events via the track() method:

import { ekoWebPixel } from '@ekolabs/eko-gallery-react';

ekoWebPixel.track('pixel.page_viewed');
ekoWebPixel.track('pixel.product_viewed', { ... });
ekoWebPixel.track('pixel.cart.add', { ... });
ekoWebPixel.track('pixel.cart.remove', { ... });

// For traffic allocation:
ekoWebPixel.track('trafficallocation.decision', { ... });

// For non shopify backend stores:
ekoWebPixel.track('pixel.checkout', { ... });
ekoWebPixel.track('pixel.order', { ... });

Report on route changes:

import { ekoWebPixel } from '@ekolabs/eko-gallery-react';

ekoWebPixel.onRouteChanged();

Keywords

eko

FAQs

Package last updated on 19 Feb 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts