JSPM

convertloop

0.1.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q43978F
  • License MIT

NodeJS wrapper for convertloop API

Package Exports

  • convertloop

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (convertloop) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ConvertLoop Node API Client

A Node client of the ConvertLoop REST API. You can sign up for a ConvertLoop account at https://convertloop.co.

Installation

$ npm install convertloop

2. Configure the ConvertLoop object passing your credentials.

const Convertloop = require('convertloop-node')

const convertloop = new Convertloop({
  app_id: 'your_app_Id',
  api_key: 'your_api_key'
})

You are now ready to start calling the API methods!

Getting Started

Creating or updating a person

You need to pass at least one of the following: pid, user_id or email to identify a user. Use pid when you are updating a guest of your site (you can obtain this value from the cookie dp_pid). Use user_id to match the id of the user in your application.

convertloop.people.create_or_update({
  email: "juan.gomez@convertloop.co",
  first_name: "Juan",
  last_name: "Gomez"
}, function(err, data) {
  console.log(err, data.body)
})

Any key different to pid, user_id, email, first_seen_at, last_seen_at, add_tags, and remove_tags will be treated as a custom attribute of the person.

You can add or remove tags using the add_tags and remove_tags keys:

convertloop.people.create_or_update({
  email: "juan.gomez@convertloop.co",
  add_tags: ['Learn Something'],
  remove_tags: ['Lead']
}, function(err, data) {
  console.log(err, data.body)
})

Logging an event

You can log an event for any person:

convertloop.event_logs.event_logs.send({
  name: 'Billed',
  person: {email: 'node@node.com'},
  metadata: {
    credits: 1000
  },
  occurred_at: new Date()
}, function(err, data) {
  console.log(data.body)
})

If you don't specify the ocurred_at key, the current time will be used. You can use the person key to add custom attributes and tags to that person.