MGID integration: Kiwify (via webhook)

This article provides a step-by-step guide on integrating Kiwify via webhook in the MGID dashboard.

A webhook is a way for web applications to send automatic notifications or callbacks to other applications in real time. It eliminates the need for constant checking by allowing applications to communicate directly when specific events occur. It can be used for tasks like receiving payment notifications, integrating with social media, automating actions, and enabling application-to-application data exchange.

Part 1: Create a goal in the MGID dashboard

Log in to 

  1. Create a new goal, “Postback.”
  2. The name of the goal should be “webhook.”


3. Save the goal

4. Add Custom Tagging src={click_id}


Part 2: Passing query parameters to Kiwify checkout

To pass parameters to Kiwify checkout, you need to add the following code to all the pages that the user visited before landing on the Kiwify checkout page.


    document.addEventListener('DOMContentLoaded', function() {

        var links = document.querySelectorAll('a');

        var urlParams = new URLSearchParams(;

        if (urlParams.toString() === '') {



        for (var i = 0; i < links.length; i++) {

            var link = links[i];

            var linkUrl = link.href;

            var hashIndex = linkUrl.indexOf('#');

            var urlWithoutHash = linkUrl;

            var urlHash = '';

            if (hashIndex !== -1) {

                urlWithoutHash = linkUrl.substring(0, hashIndex);

                urlHash = linkUrl.substring(hashIndex);


            var existingParams = new URLSearchParams(urlWithoutHash.split('?')[1]);

            urlParams.forEach(function(value, key) {

                if (!existingParams.has(key)) {

                    existingParams.append(key, value);



            link.href = urlWithoutHash.split('?')[0] + '?' + existingParams.toString() + urlHash;




This code ensures that when you click on a link, any query parameters from the current page's URL are added to the destination URL of the link. In this way, the same information is carried over to the next page.

For example, if the current page has a URL like "" and there is a link to "," this code will modify the link to "" so that the "search" query parameter is preserved when you click on the link.

To check if the parameters are passed correctly, you need to examine the URL of your Kiwify checkout page. Your URL should have the "adclid" parameter filled with the click ID from the side.

Here's an example: adclid=c2FuZGJveF8xNjEzMDU3MV8xNjg0NDE0MTEwX3NhbmRib3g1

Part 3: Setup integration on the Kiwify side

  1. Log in to 
  2. Click on APPS > Webhook


3. Click on (Criar webhook) Create Webhook


4. Paste webhook URL
5. Select the event name that you want to track. For instance, “Compra Aprovada” if you want to track paid orders.

For now, you can track only one goal using this method.