What is a Hook?
A hook is a mechanism that enables apps to receive data updates in real time, and that connects two different applications. The Countly Hooks plugin will bring together triggers and effects. It is incredibly helpful when you're working with data updates that need to be notified immediately such as payment transactions and purchasing process. The Hooks plugin allows you to capture events and user data from Countly, or post data to Countly via generated API endpoint. When an event is captured on the Hook, it serializes data about that event and you can choose to send this data by HTTP request or email. It allows creating rules, where each rule would have one trigger, and one or many effects.
The Hooks plugin allows you to listen to triggers on incoming data and internal events on Countly, which will then send relevant data to an external URL in real-time or send an email. In other words, Hooks let you transfer data to other services you used when events happen in your Countly account.
You can trigger a Hook via:
- Incoming Data
- Internal Event
- API endpoint
Internal Events are affected by the plugins that generate the event data, some of which are only available in Countly Enterprise Edition. Click here to review which plugins are available for your Countly Edition.
Creating a New Hook
You can access the Hooks plugin in the Utilities section.
To create a hook, click the
+ New Hook button on the right-top of the page.
Give the hook a name, but keep it simple, understandable, and short. You may use Hook Description field to explain to your colleagues why you created this hook. Avoid using special characters or long descriptions.
Select an application for the hook. You can select only one application for each hook.
There are 3 options to trigger a hook:
It listens to events defined for the selected application, checks for matching data, and triggers an effect if matching data is found. You can filter the events by event or user properties.
Countly has many internal events, like entering or exiting cohorts. You can specify which cohort to listen to, or which system logs action, etc. In addition to that, you can track user profile changes, namely user profile creations, updates, and deletions.
Note that Internal Events will depend on the plugins available for your Countly Edition.
These internal events could be like:
It is important to note that /userprofile/update will also get triggered when a new user created will output updated user properties. The old user profile can also be added in order to allow Hook consumers to do a comparison.
After defining the trigger, the next step is to select the Action. You can select one of these two options:
- Send an email: This action enables you to send an internal email with data from the trigger, which can be formatted as a nested list for displaying JSON objects.
- Make HTTP Request: You can simply provide a URL to call and pass the data from the trigger. It allows you to select either call via GET or POST.
POST data: this makes a POST request to a URL.
GET data: this makes a GET request to a URL with query data.
It is possible to add more than one action for a selected trigger on a hook by using the
+ Add action button.
After filling and selecting the mandatory fields, click the
Create hook button.
You can use the Hooks table to get an overview of created hooks. If you want to disable any hook, use the toggle button on the Status column. Also, you can edit or delete your hooks by clicking the 3-dot overflow menu on the right side of the Hook rows, and by clicking