Skip to main content

Integrate your Pyramid app with Customer.io

License: MIT Built by these great folks! Talk to us in #pyramid on Libera.Chat IRC

Opinionated Customer.io integration

The reason this package exists is to provide sane defaults when integrating with Customer.io. Instead of chasing down event name typos and debugging why tracking does not work, you can focus on building meaningful customer relationships.

  • You never have typo-duplicated events in Customer.io, because every event name comes from a dataclass, never from a string that can be miss-typed by mistake.
  • Same for properties. Like events, properties are hardcoded as dataclasses.
  • All "special" and "reserved" events and properties are already provided, no need to chase them down in various Customer.io docs.
  • Your app never stops working if Customer.io is down, but you still get errors in your logs so you know what is going on.
  • You never forget to call flush() on the events buffer, since pyramid_customerio hooks into the request life-cycle and calls flush() at the end of the request processing.
  • You defer sending events until the entire request is processed successfully, i.e. never send events like "User added a thing" if adding the thing to DB failed at a later stage in the request life-cycle.

Getting started

Install the package:

pip install pyramid_customerio

Or if you're using Poetry:

poetry add pyramid_customerio

Include the package in your Pyramid app configuration:

config.include('pyramid_customerio')

Configure your Customer.io credentials:

customerio.tracking.site_id = <your-site-id>
customerio.tracking.api_key = <your-api-key>
customerio.tracking.region = us  # or 'eu'

Start tracking events and identifying users:

def my_view(request):
    # Track an event
    request.customerio.track(
        request.customerio.events.user_signed_up,
        {request.customerio.event_properties.path: request.path}
    )

    # Identify a user
    request.customerio.identify({
        request.customerio.profile_properties.email: 'user@example.com',
        request.customerio.profile_properties.name: 'John Doe'
    })

Objects

Customer.io Objects are non-person entities, such as companies or accounts, that people relate to. Declare your object types and the properties allowed on them, then identify objects and relate people to them the same way you identify people:

from dataclasses import dataclass
from pyramid_customerio import ObjectProperties
from pyramid_customerio import ObjectType
from pyramid_customerio import ObjectTypes
from pyramid_customerio import Property
from pyramid_customerio import RelationshipProperties


@dataclass(frozen=True)
class MyObjectTypes(ObjectTypes):
    # The id comes from your workspace's Objects settings
    company: ObjectType = ObjectType("1")


@dataclass(frozen=True)
class MyRelationshipProperties(RelationshipProperties):
    role: Property = Property("role")


def my_view(request):
    request.customerio.identify_object(
        request.customerio.object_types.company,
        "acme",
        {request.customerio.object_properties.name: "Acme Inc."},
        relationships={
            request.user.distinct_id: {
                request.customerio.relationship_properties.role: "admin"
            }
        },
    )
customerio.object_types = myapp.customerio.MyObjectTypes
customerio.relationship_properties = myapp.customerio.MyRelationshipProperties

Releasing

Release instructions are in RELEASING.md.

Development

This project uses Nix for development environment management and Poetry for Python dependency management.

Setup

# Enter the Nix development shell
nix-shell

# Install dependencies
make install

Running tests

# Run all tests with coverage
make test

# Run only unit tests
make unit

# Run specific tests
make unit filter="test_name"

Code quality

# Run linting
make lint

# Run type checking
make types

# Format code
make format

License

MIT

Metadata

Release files for pyramid-customerio 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyramid-customerio 1.1.0
File Size Uploaded Provenance Actions
pyramid_customerio-1.1.0.tar.gz 18.6 kB With provenance Details for pyramid_customerio-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyramid-customerio 1.1.0
File Interpreter ABI Platform Actions
pyramid_customerio-1.1.0-py3-none-any.whl Python 3 none any Details for pyramid_customerio-1.1.0-py3-none-any.whl

Total release size: 39.5 kB

Release files / pyramid_customerio-1.1.0.tar.gz

Download URL pyramid_customerio-1.1.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
63596f860f8e43a4b96a1ca621d5ccd5229a0defa8435b0870fe15508284e290
BLAKE2b-256 checksum
How to use checksums
564dc50a44ab9600dabe9b84b8660ff59e91946fbcc2c944ef2598788d53b19a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / pyramid_customerio-1.1.0-py3-none-any.whl

Download URL pyramid_customerio-1.1.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0518efa5e33a7637ce90dfdb748e69b5baec5f508d50b5dcd49d698beb8bcb8e
BLAKE2b-256 checksum
How to use checksums
743264fa127e0911ee0ef51d817f93bf49c6bc7a1b2c5dd8658638273dd93be6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for pyramid-customerio 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pyramid_customerio-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page