How to use the analytics-events.productAdded function in analytics-events

To help you get started, we’ve selected a few analytics-events examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github segmentio / analytics.js-integrations / integrations / pinterest-tag / lib / index.js View on Github external
Pinterest.prototype.getPinterestEvent = function(segmentEvent) {
  for (var mappedEvent in this.options.pinterestEventMapping) {
    if (mappedEvent.toLowerCase() === segmentEvent.toLowerCase()) {
      return this.options.pinterestEventMapping[mappedEvent];
    }
  }

  var eventMap = [
    // Segment Inbound Event (Regex) -> Pinterest Outbound Event
    [analyticsEvents.productsSearched, 'Search'],
    [analyticsEvents.productListFiltered, 'Search'],
    [analyticsEvents.productAdded, 'AddToCart'],
    [analyticsEvents.orderCompleted, 'Checkout'],
    [analyticsEvents.videoPlaybackStarted, 'WatchVideo']
  ];

  for (var index in eventMap) {
    if (!eventMap.hasOwnProperty(index)) continue;
    var eventRegex = eventMap[index][0];
    var pinterestEvent = eventMap[index][1];

    if (eventRegex.test(segmentEvent)) {
      return pinterestEvent;
    }
  }
};

analytics-events

[![CircleCI](https://circleci.com/gh/segmentio/analytics-events.svg?style=shield&circle-token=db50dfacf7f315d6090978ed2b4e15924297ab17)](https://circleci.com/gh/segmentio/analytics-events) [![Codecov](https://img.shields.io/codecov/c/github/segmentio/anal

MIT
Latest version published 4 years ago

Package Health Score

51 / 100
Full package analysis

Similar packages