Giter Club home page Giter Club logo

customerio-python's Introduction

Customer.io Python bindings

This module has been tested with Python 2.7.

Installing

pip install customerio

Usage

from customerio import CustomerIO
cio = CustomerIO(site_id, api_key)
cio.identify(id=5, email='[email protected]', name='Bob', plan='premium')
cio.track(customer_id=5, name='purchased')
cio.track(customer_id=5, name='purchased', price=23.45)

Instantiating customer.io object

from customerio import CustomerIO
cio = CustomerIO(site_id, api_key)

Create or update a Customer.io customer profile

cio.identify(id=5, email='[email protected]', name='Bob', plan='premium')

Only the id field is used to identify the customer here. Using an existing id with a different email (or any other attribute) will update/overwrite any pre-existing values for that field.

You can pass any keyword arguments to the identify and track methods. These kwargs will be converted to custom attributes.

See original REST documentation here

Track a custom event

cio.track(customer_id=5, name='purchased')
cio.track(customer_id=5, name='purchased', price=23.45)

You can pass any keyword arguments to the identify and track methods. These kwargs will be converted to custom attributes.

See original REST documentation here

Backfill a custom event

from datetime import datetime, timedelta

customer_id = 5
event_type = "purchase"

# Backfill an event one hour in the past
event_date = datetime.utcnow() - timedelta(hours=1)
cio.backfill(customer_id, event_type, timestamp, price=23.45, coupon=True)

event_timestamp = 1408482633
cio.backfill(customer_id, event_type, event_timestamp, price=34.56)

event_timestamp = "1408482680"
cio.backfill(customer_id, event_type, event_timestamp, price=45.67)

Event timestamp may be passed as a datetime.datetime object, an integer or a string UNIX timestamp

Keyword arguments to backfill work the same as a call to cio.track.

See original REST documentation here

Delete a customer profile

cio.delete(customer_id=5)

Deletes the customer profile for a specified customer.

This method returns nothing. Attempts to delete non-existent customers will not raise any errors.

See original REST documentation here

You can pass any keyword arguments to the identify and track methods. These kwargs will be converted to custom attributes.

Note regarding timestamps

The library will automatically convert any datetime objects into UNIX timestamps, but assumes that you are using naive (not TZ-aware) datetime objects when generating a timestamp. Please ensure that any datetime objects get converted into a naive form before sending with customerio-python.

Thanks

customerio-python's People

Contributors

hownowstephen avatar sud0n1m avatar orblivion avatar ryanwitt avatar ebutleriv avatar jrallison avatar dimier avatar darrellsilver avatar zbyte64 avatar mationai avatar

Watchers

Kyle Mulka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.