0.0.1 • Published 2 months ago

@amplitude/plugin-default-event-tracking-advanced-browser v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

@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

NameTypeDefaultDescription
cssSelectorAllowliststring[]undefinedWhen provided, only allow elements matching any selector to be tracked.
pageUrlAllowlist(string\|RegExp)[]undefinedWhen provided, only allow elements matching URLs to be tracked.
shouldTrackEventResolver(actionType: ActionType, element: Element) => booleanundefinedWhen provided, overwrite the default filter behavior.
dataAttributePrefixstring'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');
0.8.0

2 months ago

0.7.2

2 months ago

0.7.1

2 months ago

0.7.0

2 months ago

0.6.0

3 months ago

0.5.1

3 months ago

0.5.0

3 months ago

0.4.2

4 months ago

0.4.1

4 months ago

0.4.0

4 months ago

0.3.1

5 months ago

0.3.0

6 months ago

0.1.0

7 months ago

0.2.1

6 months ago

0.1.2

7 months ago

0.2.0

6 months ago

0.1.1

7 months ago

0.0.2

7 months ago

0.1.3

7 months ago

0.0.1

7 months ago