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.

This part 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.

Here are different methods to track purchases:

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 prevent duplicate. 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