Cancel Flows / Cancel Flows Implementation
Cancel Flows Implementation
Technical reference for the Cancel Flows snippet, covering the code, how it finds your cancel button, the webhooks, and how to confirm it loaded.
This page is the technical reference for whoever installs the Cancel Flows snippet on your customer portal. The onboarding steps, from enabling Cancel Flows through go-live, are in Getting Started. Send any questions to support@churnbuster.io.
Add the snippet to your customer portal
Add this snippet to the <body> of the portal page where customers cancel. It stays inactive until we enable Cancel Flows on your account, so you can install it early.
<script type="text/javascript">
(function () {
ChurnBuster = window.ChurnBuster || {};
ChurnBuster.cancelAttributes = {
accountId: "INSERT_CHURN_BUSTER_ACCOUNT_ID",
source: "REPLACE_ME",
customerId: "REPLACE_ME",
customerEmail: "REPLACE_ME",
cancelButtonSelector: "REPLACE_ME",
customProperties: {
"productName": "REPLACE_ME",
"customer": {
"subscription_count": "REPLACE_ME",
"subscriber_LTV": "REPLACE_ME"
}
}
};
var script = document.createElement("script");
script.type = "text/javascript";
script.async = true;
script.src = "https://proxy-assets.churnbuster.io/v4/scripts.js?v=1678742553659";
var insert = document.getElementsByTagName("script")[0];
insert.parentNode.insertBefore(script, insert);
})();
</script>
Your Churn Buster Account ID is on the API sources page.
Fill in the attributes for each customer
The page fills in these values for the customer who is logged in.
-
source, the subscription platform the customer belongs to, such as"stripe". -
customerId, the customer's ID in that platform. -
customerEmail, the customer's email address.
accountId is your fixed Churn Buster Account ID from the API sources page.
cancelButtonSelector is optional and the same for every customer. The next section covers how to set it.
customProperties is optional. Properties you pass there reach Churn Buster with each session, and Segmentation can use them to run different flows for different customer types.
How the snippet finds your cancel button
Set cancelButtonSelector to a CSS selector that matches the cancel button or link on your portal, such as .cancel-subscription. A selector is the verified setup path for this snippet.
Some integrations can use a text fallback when the button or link reads "cancel subscription", but the selector avoids ambiguity when your portal labels the button differently or the same text appears elsewhere on the page. If a portal or theme update changes the button, update the selector to match.
Confirm the snippet loaded
Open a customer account page on your portal, right-click, choose Inspect, and open the Console tab. Search for "Churn Buster". Before we enable Cancel Flows, you'll see Churn Buster: Cancel Flows are disabled, which confirms the snippet loaded. If nothing appears, the snippet isn't running on that page.
Webhooks for offers and cancellations
Churn Buster sends two cancel flow webhooks, and you can use them to act on how each session ends.
- Cancel session won fires when a customer accepts an offer. Use it for backend actions your integration doesn't apply for you, such as adding a discount or skipping an order.
- Cancel session lost fires when a customer cancels. On supported platforms Churn Buster cancels the subscription for you, and with a custom integration you can use this webhook to process the cancellation yourself.
You can set up both on the webhook settings page or route them through Zapier. If you'd rather apply offers by hand, turn on email alerts for won sessions.
Where to go next
These pages cover the parts of Cancel Flows the snippet connects to.
- Cancel Flows Overview, how exit surveys, deflections, and offers fit together.
- Deflections, the value reminders and easy ways to put off cancelling.
- Targeted Offers, the offers a won session can trigger.
- Segmentation, running different flows for different customer types.
- Analytics & Insights, measuring saves and offers over time.