Jump to content

How to track sales in WHMCS with Facebook Pixel?


Looper

Recommended Posts

  • 1 month later...

Well for starters you can do the following in your templates complete.tpl file

Under:

        {if $ispaid}
            <!-- Enter any HTML code which should be displayed when a user has completed checkout here -->
            <!-- Common uses of this include conversion and affiliate tracking scripts -->

 

Add something like below:


        {literal}
                  <script>
                        fbq('track', 'Purchase', {currency: "AED", value: 1.00});

                  </script>                      
        {/literal}

 

 

I think the above could work.

Link to comment
Share on other sites

On 9/11/2024 at 4:30 PM, Looper said:

I added Facebook Pixel code using a hook, and it's working just fine. However, I want to set up an event to capture sales, such as when someone makes a purchase. How can I track that in WHMCS?

I used this hook to add the pixel:

brave_bE5BxPkfd3.png.9ecaff5526eae6147e6874b462e852b7.png

I am facing the same problem, have you found any working solution yet?

Link to comment
Share on other sites

  • 10 months later...

That's a great question, and it's essential to track sales accurately for campaign optimization.

The approach using `complete.tpl` is the standard client-side method, and the user sahostking is on the right track by suggesting the `fbq('track', 'Purchase', {currency: "AED", value: 1.00});` event.

However, you need to make sure the currency and value are dynamically pulled from the completed order, not hardcoded as $1.00 AED, which requires integrating WHMCS's Smarty variables into the template.

Also, a modern, more robust solution involves server-side tracking to combat browser limitations.

The best solution today is to combine the WHMCS API with the Facebook Conversions API, orchestrated using Google Tag Manager and a server-side tagging solution like Stape or Google Cloud Platform.

This setup provides superior data accuracy compared to client-side-only pixel tracking.

The client-side Facebook Pixel, which you added via a hook, is vulnerable to ad blockers, browser privacy features like Intelligent Tracking Prevention (ITP) in Safari and Firefox, and poor network connectivity, which can all lead to underreported conversions.

The Facebook Conversions API (CAPI) allows your server to send conversion data directly to Facebook.

You can use a WHMCS hook or the WHMCS API to capture the sales event details, like when an invoice is marked as paid, and then send this data to your server-side Google Tag Manager container.

This GTM server container, hosted on a service like Stape or Google Cloud Platform, acts as a centralized data router.

When the WHMCS server sends a "Purchase" event with the order value, currency, and customer identifiers (like hashed email) to this endpoint, the GTM server can forward that information using the Facebook Conversions API tag.

This method is better because it ensures more reliable and complete tracking, as it bypasses many client-side restrictions.

Crucially, sending customer data like email and phone number from the server allows Facebook to hash this information securely and use it to better match the conversion event to the correct user on the platform, significantly improving the Event Match Quality score and, ultimately, campaign performance.

Furthermore, by using both the client-side pixel and the server-side Conversions API, you can implement deduplication by sending a unique "event_id" for both events, ensuring Facebook doesn't count the same purchase twice but uses the more reliable server data.

This creates a resilient, privacy-friendly, and highly accurate tracking mechanism for your Purchase events.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated