Using webhooks to measure calls as conversions in Google Analytics
You can use webhooks in our cloud PBX for many purposes. One you might not think of immediately is tracking your offline conversions. When you’re running a campaign people might call you about it, instead of clicking a button (which you could already track). So how do you incorporate that call in your analytics data? Well, you can use the webhooks feature in your Axeos pbx and be ready in three simple steps:
- define your call goal and conversion in Google Analytics
- Add a webhook rule to your pbx dialplan
- Call and check your analytics dashboard
What happens is when your office recieves a call the pbx does a POST request to Google’s API, including this event type and your tracking code in the request body. Analytics will then register the call for your campaign. Let’s set this up!
Prerequisites: you need to have a google analytics account. Don’t have one? You can register here.
Step 1. Define your call goal and conversion in Google Analytics
Login to your analytics account and define a new goal, e.g. “call”. Now there’s lot of options to choose from when using goals and conversions. While we want to enable you to use this we’re no online marketing specialists ourselves, so we’re keeping this article pretty simple. Luckily Google has done a great job documenting this in their measurement protocol overview. They have a developer guide and a parameter reference which lists all of the parameters for the Measurement Protocol. You can use these to explore further what Analytics can do for you.
Google’s hit builder is a great way to choose your parameters and validate if they are indeed correct, before proceeding to the next step.
Step 2. Add a webhook rule to your dialplan
You can use webhooks anywhere in your dialplan, wherever you want to trigger the goal action. In this example we’re just adding it to our main DID. Add a webhook rule (before version 4.1.0 known as ‘data collection’ rule).
- Rule type: webhook (data collection)
- Prompt (empty)
- Number of digits: (empty)
- Exact length: (off)
- Service URL: https://www.google-analytics.com/collect
- Request body:
- Response body regexp: (empty)
- On success: continue
- Condition: unconditionally
- Description: that’s up to you 🙂
Request body details:
- v = versiont
- = hit typetid = tracking ID / web
- property ID
- cid = required if User ID (uid) is not specified in the request. This anonymously identifies a particular user, device, or browser instance. The value of this field should be a random UUID (version 4) as described in http://www.ietf.org/rfc/rfc4122.txt.
- ea = event action
Note that you need to replace the tid ‘UA-XXXXX’ with your own tracking ID and the ea ‘call’ with the name you’ve given your event.
Step 3. Make a call and check your analytics dashboard