@shopify/web-pixels-extension
TypeScript icon, indicating that this package has built-in type declarations

2.18.0 • Public • Published

Web Pixels Extension

Provides an register method to register a Web Pixels Extension.

Installation

$ yarn add @shopify/web-pixels-extension

Usage

Registering a Web Pixels Extension:

import {register} from '@shopify/web-pixels-extension';

register(({configuration, analytics, browser, init}) => {
  window.my_pixel.configure({
    pixelId: configuration.pixelId,
    href: init.context.window.location.href,
    origin: init.context.window.location.origin,
  });

  analytics.subscribe('page_viewed', async (event) => {
    const cookieValue = await browser.cookie.get('my_pixel_cookie');

    window.my_pixel.publish('page_viewed', {
      href: event.context.window.location.href,
      origin: event.context.window.location.origin,
      cookie: cookieValue,
    });
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i @shopify/web-pixels-extension

Weekly Downloads

11,805

Version

2.18.0

License

MIT

Unpacked Size

235 kB

Total Files

60

Last publish

Collaborators

  • shopify-admin
  • shopify-dep
  • mishsmelle
  • netlohan
  • pmoloney89
  • maryharte
  • jaimie.rockburn
  • jaykay101