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

2.4.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

20,960

Version

2.4.0

License

MIT

Unpacked Size

504 kB

Total Files

60

Last publish

Collaborators

  • jaimie.rockburn
  • blittle
  • shopify-admin
  • maryharte
  • crisfmb
  • pmoloney89
  • netlohan
  • st999999
  • justin-irl
  • megswim
  • wcandillon
  • nathanpjf
  • shopify-dep
  • goodforonefare
  • lemonmade
  • vsumner
  • wizardlyhel
  • antoine.grant
  • tsov
  • andyw8-shopify
  • henrytao
  • hannachen
  • vividviolet
  • bpscott