WooCommerce Zapier Purchase Template

How to send WooCommerce purchases into Zapier and then into Funnelytics

Create a Trigger in Zapier

Select the Webhooks by Zapier app as a trigger. Choose the Catch Raw Hook option as the trigger event.

 

Get the webhook URL from Zapier and add that to your funnel in WooCommerce under Settings > Advanced > Webhooks.

 

Add the URL for the "order.created" topic.

 

Be sure to test your funnel so Zapier can have some data to work with.

 


 

Zapier Action: Code

The first action in the zap needs to be this code action. This will format the webhook payload that was received into the format that Funnelytics is expecting.

 

Open the Customize Run Javascript Dropdown and apply the following settings

 

Input Data

Add a key of "body" and the value will be the raw body payload from the incoming webhook in step 1 of the zap.

 

Code

Insert this code block:

const parsed = JSON.parse(inputData.body);

return {

email: parsed.billing.email,

created_at: parsed.date_created,

items: JSON.stringify(parsed.line_items.map(line => {

return {

product_id: line.id.toString(),

product_name: line.name,

total: parseFloat(line.total),

};

})),

};

This will output the data in a nice format that you can reference in the next action.


 

Zapier Action: Webhook

The last step in the zap will be another webhook action. This one is going to send the data to Funnelytics.

Be sure to choose "Custom Request" as the action event.

 

Follow the format of the code outlined in this article.

 

 

 

Method: Post
URL: https://track-v3.funnelytics.io/events/commerce
Data Pass-Through: False
Data: {

"email": "",

"datetime": "",

"items":

}

Unflatted: Yes
Basic Auth: leave blank

Headers: Content-Type and Authorization

In the data field, you can reference the output from the previous steps

 

Next Steps

Now that everything is set up, let's clear our cookies (or use another browser) and run again through our funnel in test mode, complete a test purchase and make sure that it's working as expected.

NOTE: If you are using Stripe, you shall test it in Live mode otherwise no webhook will be fired in test mode

 

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!