Do you need extra functionality that isn’t provided by WP Optin Wheel out-of-the-box? Starting from version 1.2.0, we allow everyone to extend the plugin by integrating with webhooks. This tutorial will show you how you can connect the plugin to other apps via Zapier. Here are a few use cases in which you may want an integration:
- You are using unsupported email-list software, such as Mautic. In that case, you can use Zapier to connect the two.
- You want an excel-type log file (Google Sheet) of who won, and what exactly they won.
Before We Begin
Before we begin, I’d like to explain the 2 types of events you can attach a webhook to. They can be seen in the settings of each wheel.
- The optin event: this event occurs when a user enters their data (email address along with other fields you defined) in the form on the wheel. In essence, this happens right before they play. The event carries the user data with it.
- The play event: this occurs whenever a user plays. Depending on your configuration, this event can occur multiple times for the same user. This event contains the winning/losing data.
With both events, the user’s email address is the unique key and can be used to link the two events together, should you need to.
Step 1: Create a New Zap
We’re going to create a Zap that will connect WP Optin Wheel with Google Sheets to create a real-time log file of everyone who played the wheel.
Let’s head over to the Zapier website and create a new Zap by clicking Make A Zap (register first if you need to).
Give your Zap a name and select Webhooks under Built-In Apps as the trigger app.
On the next screen, select Catch Hook and press Save + Continue.
The next step (configuring the webhook) is not compulsory, so just click Continue.
Step 2: Test the webhook
It’s time to test your webhook. To do so, copy the webhook link as shown in the screenshot below and click Okay, I did this. You’ll notice Zapier is waiting for you to test the hook ( “Looking for the hook, this might take a sec…”).
Now paste the webhook link into the play webhook setting of WP Optin Wheel and save the wheel.
Next, Zapier needs to know what data is being sent to its webhook. This can be done by spinning the wheel once on your website. It’s tedious, I know, but it’s the only way for Zapier to know what data you are sending to the webhook. So play the wheel once on your website as a test – you can use fake data.
When this is complete, you’ll notice Zapier has captured the data. It will inform you that testing is complete. Click Continue.
Step 3: Set Up Google Sheets
Now it’s time to prep a Google Sheet to list all wins & losses. Head over to Google Docs and create a new sheet. Set up the header columns as seen in the screenshot below:
Here’s a description of each column:
- Email: this will contain the player’s email address.
- Play Number: the current play number. If you allow users to play multiple times, it will say so here.
- Winning: did the user win? 1 = true. 0 = false.
- Coupon Code: the coupon code the user won (if applicable).
- DateTime: the date & time the user played.
Step 4: Add Google Sheets to the Zap
Now that our trigger application (the webhook) is completely set up and tested, Zapier asks us to select an action application. Select Google Sheets.
In the next step, select Create Spreadsheet Row and click Save + Continue.
Zapier will also ask you to connect your Google account. Go ahead and connect your account and click Save + Continue.
Next up, you should select the correct Google Sheet, as created in step 3:
Once that is done, Zapier will show you all the available columns in your sheet. Now it’s up to you to link the correct data from the webhook to the correct column in the sheet. Once you’re done, it should look like this:
Click Continue a few times to finish & save the Zap. Don’t forget to turn it on!
The Final Result
The final result is a Google Sheet that will automatically be populated with all the wins and losses from your wheel. This provides you with a nice overview, and you can even send this data to another system for further processing.