A third party maintained Node.js package for sending Klaviyo events
Klaviyo is a real-time service for understanding your customers by aggregating all your customer data, identifying important groups of customers and then taking action. http://www.klaviyo.com/
- Track customers and events directly from your backend.
npm install klaviyo-node
After installing the klaviyo package you can initiate it using your public token which is for track events or identifying profiles and/or your private API key to utilize the metrics and list APIs.
const Klaviyo = require('klaviyo-node');
client = new Klaviyo(PUBLIC_TOKEN);
You can then easily use Klaviyo to track events or identify people. Note, track and identify requests take your public token.
// Track an event...
client.track('Filled out profile', {
'$email': '[email protected]',
// and/or id
// '$id': 'XXXXXXXXXXXX',
}, {
'Added social accounts': false,
});
// you can also add profile properties
client.track(
'Filled out profile',
{
'$email': [email protected]',
'$first_name': 'Thomas',
'$last_name': 'Jefferson'
....
},
{
'Added social accounts': false,
}
);
// ...or just add a property to someone
client.identify({
'$email': '[email protected]',
'$id': 'XXXXXXXXXXXX',
'$first_name': 'Thomas',
'$last_name': 'Jefferson',
'Plan': 'Premium',
});
More details about the Klaviyo API can be found here: https://www.klaviyo.com/docs/http-api
The methods in the package are documented in the docs folder of the repository.
Everyone is welcome to contribute to this package. Simply make sure there are no errors and your contribution passes the CircleCI test and we will review and hopefully merge your changes.
This package uses yarn
as a package manager, which provides several benefits over npm
. After having run npm install
, you should be able to use the yarn
command in your CLI.
To make sure your package is ready for a Pull Request, please run yarn build
. The build script will check styling, create documentation (you should check in the changes in the /docs
folder) and check the spelling in your documentation.
This package uses jest
to run tests. You can easily run all the tests using yarn test
.
This package uses ESLint with the Google JavaScript Style Guide. Styling is strictly enforced and CircleCI will return an error when there are styling issues with your contribution. You can run the linter by executing yarn lint
.
The Google JavaScript Style Guide enforces that JSDoc is used on all classes, fields, and methods. The JSDoc strings are used by jsdoc-to-markdown
to generate documentation in /docs
.
We like correct spelling even in documentation. A spellchecker is run on all markdown files, including the ones that were generated based on the JSDoc strings and a Pull Request will fail checks if there are spelling issues. The spellchecker doesn't recognize parameter, method, and class names and those obviously don't need to be English words. To make sure your new parameter, method, and class names are accepted by the spellchecker, you can run yarn spelling
to interactively add these names to the local dictionary (.spelling
).