This article provides a step-by-step guide on integrating Braip.com 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 into https://dashboard.mgid.com/
- Create a new goal “Postback”
- The name of the goal should be “webhook.”
4. Save the goal
Part 2: Passing query parameters to Braip checkout
To pass parameters to Braip checkout, you need to add the following code to all the pages that the user visited before landing on the Braip checkout page.
<script>
document.addEventListener('DOMContentLoaded', function() {
var links = document.querySelectorAll('a');
var urlParams = new URLSearchParams(window.location.search);
if (urlParams.toString() === '') {
return;
}
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;
}
});
</script>
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 "example.com/?search=shoes" and there is a link to "example.com/products," this code will modify the link to "example.com/products?search=shoes" 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 Braip checkout page. Your URL should have the "adclid" parameter filled with the click ID from the MGID.com side.
Here's an example: adclid=c2FuZGJveF8xNjEzMDU3MV8xNjg0NDE0MTEwX3NhbmRib3g1
Part 3: Setup integration on the Braip.com side
- Log in to https://braip.com/
- Click on (Ferramentas) Tools > Postback
3. Click on (Nova Configuração) New Setup
4. Paste webhook URL https://a.mgid.com/postback/webhook?vendor=braip
5. Select the event name that you want to track. For instance, “Aguardando pagamento” if you want to track newly created orders, or “Pagamento Aprovado” for completed orders.
For now, you can track only one goal using this method.