Skip to content

Commit fabac24

Browse files
feat: add support for invite-type anonymous event tracking (#83)
Co-authored-by: glosier <73669535+glosier@users.noreply.github.com>
1 parent 0dbcad1 commit fabac24

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ cio.track_anonymous(anonymous_id="anon-event", name="purchased", price=23.45, pr
105105

106106
An anonymous event is an event associated with a person you haven't identified. The event requires an `anonymous_id` representing the unknown person and an event `name`. When you identify a person, you can set their `anonymous_id` attribute. If [event merging](https://customer.io/docs/anonymous-events/#turn-on-merging) is turned on in your workspace, and the attribute matches the `anonymous_id` in one or more events that were logged within the last 30 days, we associate those events with the person.
107107

108+
#### Anonymous invite events
109+
110+
If you previously sent [invite events](https://customer.io/docs/anonymous-invite-emails/), you can achieve the same functionality by sending an anonymous event with the anonymous identifier set to `None`. To send anonymous invites, your event *must* include a `recipient` attribute.
111+
112+
```python
113+
cio.track_anonymous(anonymous_id=None, name="invite", first_name="alex", recipient="alex.person@example.com")
114+
```
115+
108116
### Delete a customer profile
109117
```python
110118
cio.delete(customer_id="5")

customerio/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (1, 4, 0, 'final', 0)
1+
VERSION = (1, 5, 0, 'final', 0)
22

33
def get_version():
44
version = '%s.%s' % (VERSION[0], VERSION[1])

customerio/track.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ def track(self, customer_id, name, **data):
7979

8080
def track_anonymous(self, anonymous_id, name, **data):
8181
'''Track an event for a given anonymous_id'''
82-
if not anonymous_id:
83-
raise CustomerIOException("anonymous_id cannot be blank in track")
8482
url = self.get_events_query_string()
8583
post_data = {
86-
'anonymous_id': anonymous_id,
8784
'name': name,
8885
'data': self._sanitize(data),
8986
}
87+
if anonymous_id:
88+
post_data['anonymous_id'] = anonymous_id
89+
9090
self.send_request('POST', url, post_data)
9191

9292
def pageview(self, customer_id, page, **data):

0 commit comments

Comments
 (0)