This package has been deprecated

Author message:

Package has been renamed to @amplitude/plugin-autocapture-browser. Use the new package instead.

@amplitude/plugin-default-event-tracking-advanced-browser
TypeScript icon, indicating that this package has built-in type declarations

0.0.1 • Public • Published


@amplitude/plugin-default-event-tracking-advanced-browser (beta)

This plugin is in beta at the moment, naming and interface might change in the future.

Browser SDK plugin for default event tracking advanced.

Installation

This package is published on NPM registry and is available to be installed using npm and yarn.

# npm
npm install @amplitude/plugin-default-event-tracking-advanced-browser

# yarn
yarn add @amplitude/plugin-default-event-tracking-advanced-browser

Usage

This plugin works on top of the Amplitude Browser SDK, generating auto-tracked events and sending to Amplitude.

To use this plugin, you need to install @amplitude/analytics-browser version v1.9.1 or later.

1. Import Amplitude packages

  • @amplitude/analytics-browser
  • @amplitude/plugin-default-event-tracking-advanced-browser
import * as amplitude from '@amplitude/analytics-browser';
import { defaultEventTrackingAdvancedPlugin } from '@amplitude/plugin-default-event-tracking-advanced-browser';

2. Instantiate the plugin

The plugin accepts 1 optional parameter, which is an Object to configure the allowed tracking options.

const plugin = defaultEventTrackingAdvancedPlugin({
  cssSelectorAllowlist: [
    '.amp-tracking',
    '[amp-tracking]'
  ],
  pageUrlAllowlist: [
    'https://amplitude.com',
    new RegExp('https://amplitude.com/blog/*')
  ],
});

Examples:

  • The above cssSelectorAllowlist will only allow tracking elements like:
    • <button amp-tracking>Click</button>
    • <a class="amp-tracking">Link</a>
  • The above pageUrlAllowlist will only allow the elements on URL "https://amplitude.com" or any URL matching the "https://amplitude.com/blog/*" to be tracked

Options

Name Type Default Description
cssSelectorAllowlist string[] undefined When provided, only allow elements matching any selector to be tracked.
pageUrlAllowlist (string|RegExp)[] undefined When provided, only allow elements matching URLs to be tracked.
shouldTrackEventResolver (actionType: ActionType, element: Element) => boolean undefined When provided, overwrite the default filter behavior.
dataAttributePrefix string 'data-amp-track-' Allow data attributes to be collected in event property.

3. Install plugin to Amplitude SDK

amplitude.add(plugin);

4. Initialize Amplitude SDK

amplitude.init('API_KEY');

Readme

Keywords

none

Package Sidebar

Install

npm i @amplitude/plugin-default-event-tracking-advanced-browser

Weekly Downloads

4,810

Version

0.0.1

License

MIT

Unpacked Size

198 kB

Total Files

57

Last publish

Collaborators

  • dnshi
  • rctbusk
  • curtisbliu
  • nutwani
  • kelson.warner
  • ajhorst_amp
  • brian.giori
  • sdk.dev
  • kevinpagtakhan
  • amplicynthia
  • jimmynotjim