Revenue/conversion tracking on Facebook & Google Analytics Answered
I had been trying to figure out revenue/conversion tracking on Facebook & Google Analytics for a while, and have now got it working.
If you use a “thank you” page after checkout complete and you want to send a revenue number to Facebook Ads or Google Analytics, here is a script that you can add to your page.
It still has a few caveats - if anyone would like to help improve it, please feel free!
- doesn’t factor in discounts/trials
- my script uses EUR - change this for your currency
- I’m pretty sure it will double count if a user refreshes the thank you page
- Note, you need the GA4 tag set up on your website
Hope this is useful to someone - it would have been useful to me 🙂
<script>
const memberstack = window.$memberstackDom;
memberstack.getCurrentMember().then(({ data: member }) => {
const planConnections = member.planConnections;
// Check if there are any plan connections
if (planConnections && planConnections.length > 0) {
const lastPlanConnection = planConnections[planConnections.length - 1];
const fbAmount = lastPlanConnection.payment.amount;
console.log(fbAmount);
fbq('track', 'Purchase', { currency: 'EUR', value: fbAmount });
gtag("event", "purchase", {
value: fbAmount,
currency: "EUR",
items: [
{
item_id: lastPlanConnection.planId,
price: fbAmount,
quantity: 1
}]
});
}
});
</script>
Comments
10 comments
Alastair Budge Nice, thx!
So does it only fire if the member actually has at least 1 paid plan? Or can it also fire if the member hasn't paid yet
I ask this as I noticed that sometimes my users get redirected to the succesful payment page after leaving the Stripe checkout without converting
Hmm, it will only fire if they have a plan.
Users shouldn’t be redirected to a thank-you page without a successful checkout…
I know, seemed like a bug
But that's cool. I will try and change the snippet so it checks if the browser session has a specific cookie set and only fire the event if it doesn't. Then set the cookie after that event so the event can only fire once per browser session.
Will share it later on if you want 🙂
Great! Thanks for the amazing tips Alastair Budge. But how do you redirect members to a specific page after purchase?
Aurélien Gallier undefined this comes “out of the box” with Memberstack: https://docs.memberstack.com/hc/en-us/articles/7384608370715-Default-Redirects-Plan-Redirects-Signup-Login-Logout-
Anyone running page-view based conversion tracking for Meta ads on their Memberstack app?
Have a hypothesis that my Meta custom conversion aren't getting logged due to device swapping at the email verification step.
For example, I acquire a free signup (Memberstack member created), they're prompted to verify email, and their signup redirect in Memberstack sends them to a specific page. I then redirect them from that page ~4 seconds after they hit it.
My custom conversion fires after they hit that final page. But even though I'm seeing signups, my conversions aren't firing. My concern is that users are signing up on desktop, seeing the verify email page, grabbing their phone, and then verifying from their phone (where the cookie from their browser no longer tracks them).
Anyone else even run into / solve this?
Thanks in advance for any advice you can provide 🙏
I was very recently 😄
You are almost definitely right - and most people would verify email from their phone.
Can you delay the need for email verification? Or maybe set up the conversion event ON the "check your inbox" page?
Another idea that could stop this id this doesnt work is to link to Gmail, mail app, etc directly on the site to incentivize them to use their computers... but still many will not
Can you delay the need for email verification?
Probably. How would you implement something like that?
I'm assuming I'd need a unique thank you page set up as each plan's signup redirect URL, then I'd redirect them to the verify email page after they hit the thank you page. Does that sound correct? Am I missing anything important on the Memberstack side?
To me, that sounds correct!
Thanks, Julian. Looking forward to your Finsweet stream w/ Joe. Break a leg!
Please sign in to leave a comment.