Event Tracking

Event Tracking

Event Tracking

icon
Event tracking you’ll actually enjoy

Event tracking products are difficult to test in the field and are filled with feature bloat. Our new event tracking tool lets you easily capture your products key-value metrics on a per customer basis. And better yet, we’ll automatically stitch together your event data with your customer subscription data to give you a comprehensive view of your customers.

Use Cases

  • Conversion funnel analytics
  • Customer health
  • Feature adoption reports

Publishing Events

Events are created through a simple HTTP request.

Server Side

For sending server side events, simply include your Churnkey API key as a header, as shown below.

const headers = {
	"x-ck-api-key": "YOUR_CHURNKEY_API_KEY",
	"x-ck-app": "YOUR_CHURNKEY_APP_ID",
}

const eventBody = {
  "customerId": "cus_a23kmlfg",
  "event": "newPost",
  "eventData": {
	  "postType": "image"
  }
}

axios.post("https://api.churnkey.co/v1/events/track", eventBody, headers)

const customerUpdate = {
  "customerId": "cus_a23kmlfg",
  "customerData": {
	  "numFollowers": 21600,
  }
}

Client Side

💡
Make sure to not use your secret Churnkey API key client side

Client side events can be authenticated by signing the customerId or customerEmail if the customerId is not available. Events can also be created without authentication, and will be marked as “unverified” accordingly.

For details on creating the hmacSignature , see Step 2 on our cancel flow Installation Guide.

// Optional. See Step 2 of our Installation Guide
const hmacSignature = await getSignedCustomerId(customerId) // Sign customerEmail if customerId is not available

window.churnkey.event({
  customerId: "cus_a23kmlfg",
	customerEmail: "jane@example.com",
  appId: "YOUR_CHURNKEY_APP_ID",
  authHash: hmacSignature, // Optional
  event: "newPost",
  attributes: {
    postType: "image",
  }
})

💠
h

© Churnkey, LLC