Skip to content

Repository files navigation

@adapt-retail/adapt-data Build Status

⚠️ This package has not been released as a stable release, and changes may occur.

Easy dispatching of events in Adapt Retail.

Install

npm install @adapt-retail/adapt-event

Usage

The event class will help you dispatch events in Adapt Retail. You can use it to track whatever event you like, but we got some preconfigured events for you.

Import to project

When installed, simply import the package with normal node syntax.

// EcmaScript6 and upimportAdaptEventfrom'@adapt-retail/adapt-event';

Dispatching events

/* * @param event * @param description (optional) * @param position (optional) *  * @return void */AdaptEvent.dispatch('Event name','Description');

If you dispatching an MouseEvent, add the event as the third parameter to track where the click occur.

varlogo=document.querySelector('.logo');logo.addEventListener('click',function(event){AdaptEvent.dispatch('click','on-logo',event);});

Plugins

It is possible to extend the functionality of the AdaptEvent using plugins. This could be f.eks. extending the event to match other display networks, such as Google Double Click and AdForm.

Read how to build your own in the documentation

AdaptEvent.addPlugin(newPlugin);

Default plugins

We are also including some default plugins to make your life easier.

Read more in the documentation

// Import and add pluginimport{AdaptEvent,AdaptClickEvent,AdaptGoogleAnalythics}from'@adapt-retail/adapt-event';AdaptEvent.addPlugin(newAdaptClickEvent);AdaptEvent.addPlugin(newAdaptGoogleAnalythics);// Track a click document.querySelector('.logo').adaptClick(function(event){
...
},'a-click','logo');// Track click and navigate to urldocument.querySelector('.logo').adaptClickAndNavigate('https://adaptretail.com','navigate','from-logo');

Development

# Install dependencies
npm install
# Run test suit
npm run test# Run test suite on file change
npm run tdd

About

Trigger events for Adapt Retail

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages