# Event Tracking
Event Tracking is a versatile feature designed to capture data on various contact behaviors. It allows you to programmatically create events for any activity or generate them from different automations. These events can then be utilized to filter contacts or incorporated into automation conditional logics, offering flexibility in monitoring and responding to user interactions.
There are various methods to create it. Let's go through the process step by step. Initially, we will explore how to create it using the PHP API.
Key | Type | Description | Default |
---|---|---|---|
title | String | title is required | |
event_key | String | event_key is required | |
String | |||
subscriber_id | String / Number | ||
value | String | optional field | |
provider | String | optional field | custom |
Example of PHP API
$tracker = FluentCrmApi('event_tracker')->track([
'event_key' => 'fcrm_event_tested', // Required
'title' => 'Testing FluentCRM Event', // Required
'value' => 'This is my event value with plain Text',
'email' => '[email protected]',
'provider' => 'woocommerce' // If left empty, 'custom' will be added.
], true);
2
3
4
5
6
7
Also, you can use subscriber_id
instead of email
Remember one thing, if the event_key
is the same, it will just count, don't create a new event.
# Now let's see how to create with Rest API.
API: https://your-domain.com/wp-json/fluent-crm/v2/subscribers/track-event
Body JSON
{
"event_key": "testing_from_rest_API",
"title": "Testing From REST API",
"email": "[email protected]",
"value": "This is my event value with plain Text",
"provider": "woocommerce"
}
2
3
4
5
6
7
# Now let's see how to create with Action Hook.
Example of Action Hook
do_action('fluent_crm/track_event_activity', [
'event_key' => 'fcrm_event_tested',
'title' => 'Testing FluentCRM Event',
'value' => 'This is my event value with plain Text',
'email' => '[email protected]',
'provider' => 'woocommerce'
], true);
2
3
4
5
6
7
# Get events of a single contact
If you want to see the event tracking of a single contact, let's see how you can do that.
API: https://your-domain.com/wp-json/fluent-crm/v2/subscribers/{ID}/tracking-events
Then You will get response like this:
{
"events": {
"total": 3,
"per_page": 15,
"current_page": 1,
"last_page": 1,
"next_page_url": null,
"prev_page_url": null,
"from": 1,
"to": 3,
"data": [
{
"id": 2,
"subscriber_id": "12555",
"counter": "1",
"created_by": "0",
"provider": "woocommerce",
"event_key": "fcrm_event_tested",
"title": "Testing FluentCRM Event",
"value": "This is my event value with plain Text",
"created_at": "2024-01-17 14:27:35",
"updated_at": "2024-01-17 14:27:35"
},
{
"id": 1,
"subscriber_id": "12555",
"counter": "3",
"created_by": "0",
"provider": "custom",
"event_key": "testing_from_rest_API",
"title": "Testing From REST API",
"value": "Hello There",
"created_at": "2024-01-17 14:14:44",
"updated_at": "2024-01-17 14:27:35"
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38