Add custom conversion tracking
In this help doc, we'll explain how to trace the origin of your sales with our custom conversion tracking feature.
In this help doc:
- Add custom conversion tracking code.
- Send detailed conversion data to your analytics tool.
- Track orders by members on iOS devices.
- Track members who sign up for free.
Add custom conversion tracking code
Go to Website → Checkout in your Memberful dashboard, and paste your tracking codes into the Embedded analytics code to be run when an order is successfully processed box. You can add as many tracking codes as you like. These tracking codes will be output on the order complete page whenever a customer successfully completes an order.
This will allow you to track when a member successfully completes an order. If you need to track more detailed information about the member or the order (e.g. the member's email address, the order amount, etc.), this approach won't work. You should instead send detailed conversion data to your analytics tool.
Send detailed conversion data to your analytics tool
If you're looking to send conversion data to Google Analytics, we have a direct integration with Google Analytics, which is easier to set up. For other analytics tools, read on.
Before we can send detailed information about an order and the member who placed it, we first need to fetch it. This involves writing some code, so you'll probably need help from a developer to set this up.
1) Enable our Tapfiliate integration.
This might seem counter-intuitive because you're not looking to do anything with affiliates, but you don't need to actually connect the integration to a Tapfiliate account or do anything affiliate-related.
This integration will add some data (query parameters) about the order to the URL that members are redirected to after each purchase:
- order_id: the order ID
- member_id: the member's ID
- amount: the order amount
Here's an example URL with the fields:
https://www.YOURSITE.com/purchase-confirmation/?amount=20.00&member_id=4687942&order_id=DA59BDAD-6322-49A8-92B0-653D24581728
2) Extract the order ID, member ID, and amount from the URL.
On the page that members will be redirected to after purchase, write a script extracting the order information from the query parameters in the URL.
Here's an example script that does this:
<script>
function getQueryParams(){var r={},n=function(r){return decodeURIComponent(r.replace(/\+/g," "))},t=location.search.substring(1).split("&");for(var e in t){var o=t[e].toString().split("=");o.length>1&&(r[n(o[0])]=n(o[1]))}return r}
let params = getQueryParams();
let order_id = params.order_id;
let member_id = params.member_id;
let amount = params.amount;
</script>
Now you have the order ID, member ID, and amount in variables that you can use to send this data to your analytics tool.
3) (Optional) Query our API to find out more about the order.
If you need the member's email address or further information about the order, you can call our API with a query like the following, which will fetch the order by its ID and return the member's email address and the currency.
query {
order(uuid:"YOUR_ORDER_ID") {
currency
member {
email
}
}
}
You can also modify that code to make it return other data points about the member or the order. Learn more about fetching data from our API.
4) Send the extracted data to your analytics app of choice.
Now you have the data you need to send this conversion event, including the member's email address and any other data point you got from our API, to your tracking software.
Track orders by members on iOS devices
Since iOS 14.5, Apple requires certain apps like Facebook to ask for domain verification to be able to track ad performance.
Since the conversion happens on our domain (e.g. ACCOUNT-URL.memberful.com), and not on a domain that you own, you won't be able to verify it. Therefore, the approach described above won't work.
In such cases, we recommend that you redirect to a page on your website after every purchase, so that you can insert the tracking code on that page instead of including it on Memberful's order complete page.
Contact us, and we can guide you on how to set this up.
Track members who sign up for free
The custom analytics code only works in the checkout (for paid plans). If you'd like to implement tracking for free fregistration you can redirect those free registrants to a page on your domain. You can set up the redirect via Website → External website → After free registration redirect.
Related help docs: