How to track purchase events or custom events when a user completes a purchase?

How to track purchase events or custom events when a user completes a purchase?

This guide is designed to assist you in efficiently tracking purchase events or custom events when customers make a purchase on your Knorish website.

Note: This functionality necessitates a high level of proficiency in managing tags, parameters, and a basic understanding of JavaScript. Incorrect configurations might impact the user's checkout process. The sample code provided is generated from Google Analytics and Facebook Pixel, but you can also generate tracking code from other third-party platforms based on your needs.

    Purchase tracking code in global custom code

    This feature will seamlessly track all purchase events for every course and bundle checkout, including both regular and express checkout options. Here is a comprehensive step-by-step guide on how to configure tracking using the global custom code section found on the publisher dashboard.

    • Login to publisher dashboard
    • Go to the Website builder section, then select Custom code, and finally, click on the purchase tracking tab.
    • Now paste your tracking code

    Google Analytics sample code - https://raw.githubusercontent.com/knorish/tracking-code/main/global-purchase-tracking-google-analytics.txt


    Google Analytics sample code result:


    Facebook Pixel sample code - https://raw.githubusercontent.com/knorish/tracking-code/main/global-purchase-tracking-facebook-pixel.txt



    Facebook Pixel sample code result:-


    Avoid using the sample code as-is; make sure to customize it by updating the IDs and necessary parameters as per your requirements.

    Purchase tracking code on a thank you page

    This tracking feature will only be activated when the thank you page is associated with a specific course or bundle in the after purchase settings. To set this up, you need to create a separate thank you page for each course and bundle. Avoid reusing other thank you pages with purchase tracking code, as this could result in inaccurate conversions for the wrong course or bundle.


    Follow these step-by-step instructions to set up tracking using the thank you page feature in the course and bundle after purchase setting on the publisher dashboard.

    • Login to publisher dashboard
    • Navigate to the Website builder section, click on Pages, choose the relevant thank you page, and access its settings.
    • Now paste your tracking code in the header code section.

    Google Analytics sample code -https://raw.githubusercontent.com/knorish/tracking-code/main/thankyou-page-purchase-tracking-google-analytics.txt 

    Important Note: This code snippet serves as a reference for tracking purchases. It is important to note that the transaction_id is obtained by extracting information from the URL query string. The transaction_id is generated by Google Analytics to prevent duplication; we extract the id field from the URL as an extra layer of protection against duplicacy. The remaining parameters such as course or bundle ID, name, price, and currency must be hardcoded. We have included only the necessary details required for the Google Analytics purchase tracking event.

    Facebook Pixel sample code -  https://raw.githubusercontent.com/knorish/tracking-code/main/thankyou-page-purchase-tracking-facebook-pixel.txt

    Important Note:This code snippet servers as a reference for tracking purchase. It is import to note that the id is obtained by extracting information from the URL query string to preventduplicate. The remaining parameters such as value and currency must be hardcoded. We have included only the necessary details required for the Facebook Pixel purchase tracking event.

    Tracking custom events when a purchase occurs

    If you wish to track specific custom events to trigger during a purchase (such as courses or bundles), you have the option to track them as well. Here is a comprehensive step-by-step guide on how to configure such tracking using the global custom code section found on the publisher dashboard.

    • Login to publisher dashboard
    • Go to the Website builder section, then select Custom code, and finally, click on the purchase tracking tab.
    • Now paste your tracking code

    Facebook Pixel sample code - https://raw.githubusercontent.com/knorish/tracking-code/main/global-purchase-custom-events-tracking-facebook-pixel.txt


      • Related Articles

      • How to track initiate checkout events or custom events when a user initiates a checkout?

        This guide is designed to assist you in efficiently tracking initiate checkout events or custom events when customers starts a checkout on your Knorish website. This part necessitates a high level of proficiency in managing tags, parameters, and a ...
      • How to track signup events or create custom events when a user registers?

        This guide is designed to assist you in efficiently tracking signup events or custom events when users signup/register on your Knorish website. This part necessitates a high level of proficiency in managing tags, parameters, and a basic understanding ...
      • User Engagement

        Analytics include the overview of performance, course view, assessment, the status of certificate downloads, etcfor the benefit of the course creators. This information over here would help you to learn how to access and understand the various course ...
      • How to track commissions and earnings from your Knorish Referrals?

        Tracking your Knorish Referrals and the commissions is easy. Under the referrals section, the Referral Earning dashboard is the dedicated dashboard to track your commissions and the number of academies that have been created using your referral link. ...
      • How to add a custom pop up on your site for lead generation?

        Several tools exist that help set up a pop up on your site or specific pages such as Mailchimp, Optinmonster and others. This article will show you how to add pop-ups on your Knorish Site. Pop-Ups generally are used to capture email IDs for lead ...