Collect WooCommerce purchases data using Webhooks and Integromat

Send WooCommerce purchases into Integromat and then into Funnelytics

 

Create a Scenario in Integromat

Select the WooCommerce app as a trigger.  Choose the Watch Orders option as the trigger event.

Click the Add button and give it a name in the "Create a connection" window that comes up. 


Woocommerce-WebHook-Integromat (1)

 

You can find the Consumer Key and the Consumer Secret by creating a REST API in your WooCommerce settings panel.


 

Integromat will automatically determine the structure of the data. Be sure to test your funnel so setting up the next steps will be easier.

 

Add the Iterator tool

The Iterator tool allows your Integromat scenario to read multiple products' info nested inside your data coming from Woocommerce.


Step 1. Click on the green "Cog" you can find at the bottom of your scenario page.

Step 2. Select Iterator.

Step 3. Go ahead and connect it to your Woocommerce trigger. Once done, you will be able to select the element that contains the products purchased so that Integromat can collect the information and send it to Funnelytics. The element you have to look for is named Line items.

 

Add the Aggregate to JSON module

Now that you have made all the purchased products data available to Integromat, let's arrange it in a way that the Funnelytics endpoint will easily digest.

To do this you will have to add an Aggregate to JSON module.

Step 1. Click on the little "+" icon on the bottom of the scenario page.

Step 2. Type JSON in the window that pops up,

Step 3. Select the JSON icon

Step 4. Then hit Aggregate to JSON.

 

 

Configure the Aggregate to JSON module

Configuring this module is quite easy thanks to the built-in generator, which lets you create the layout by making it read the structure of the final code we want to create.

 

json setup

 

Step 1. Start by selecting the Source of the data from the dropdown menu, which will be the Iterator.
Step 2. Then click on the Add button to create a new data structure.

Step 3. Give it a name.

Step 4. Click on Generator.

Step 5. In the new window, select JSON in the "Content-type" dropdown menu. 

{
"product_name": "my product name",
"product_id": "my product id",
"total": 0
}

Step 6. Paste the following code in the "Sample Data" field.

Integromat will then read the JSON code and will populate the "Specification" section with the three elements we need and their value type.

 

The last step is to go back to the first window of the Aggregate to JSON module and select which values shall fill those fields.

Element Value
product_id Product ID
produc_name Name
total Total

 

Every Integromat module output value will inherit the module's color so that it will be easier to spot the correct element when recalling them in a further step.

 

Add the HTTP Request

Let's get to the last piece of our puzzle, the HTTP Request module.

To add the module, we will once again click the little "+" icon that appears at the bottom of the scenario page, however, in this case, we will search for "HTTP", and the action will be Make a Request.

Woocommerce-http

 

Configure the HTTP Request module


Step 1.
Add https://track-v3.funnelytics.io/events/commerce to the URL field. 

Step 2. Select POST as the Method.

Step 3. Add two headers as detailed in the table below:

Header Name Value
1 Content-Type application/json
2 Authorization Your Funnelytics API key (you can find it in your workspace settings tab)


Step 4.
Select Raw as "Body Type"

Step 5. Set JSON (application/json) as the "Content type".

Step 6. Lastly, in "Request content paste the following code and enter your data between the empty quotes ""

{
"email": "",
"datetime": "",
"items":
}

 

Woocommerce-http2

As seen above - click the "Request Content" field to reveal the data mapping pop-up.

 

Step 1. In the Woocommerce elements look for the one that contains the User's Email and add it between the quotation marks in front of the "email": line. 

Step 2. Again, in the Woocommerce elements, look for the property that contains the order creation timestamp and add it between the empty quotation marks in the "datetime": line.

Step 3. Add the Aggregate to JSON output in the "items": line.

 

Note: be aware that Funnelytics' endpoint will accept only timestamps in the ISO 8601 format (Wikipedia): 2021-03-29T09:58Z (UTC example)


If your payment process/cart solution does not send out time data formatted this way you can always format it yourself, by adding this bit of code instead of the single time element,

"{{parseDate(Woocommerce Date Created; "YYYY-MM-DDTHH:mm:ss"; "Timezone")}}"

 

Something missing?

if something is missing in the documentation or if you found some part confusing, please reach out to support team, with your suggestions for improvement.

We love hearing from you!