SamCart integration allows you to track the regular one time orders and also recurring payments. The integration consists of adding a tracking code to checkout pages, adding a custom field to the products which should be tracked and creating a webhook which will notify a plugin in your Post Affiliate Pro.
To track recurring payments you need to use the Recurring Commissions feature!
Create a custom field
Log in to your SamCart dashboard and go to Settings by clicking in the upper right corner, then navigate to Custom Fields on the left side menu and click the Create New button.
Set the Internal Field Name to papCookie, add a label and set the field type to Text Input. The field should not be required and shouldn’t display on receipt page. Once the field is created copy its Slug value for the next step.
Add tracking code
Still under your SamCart Settings go to the General menu and insert the following code into the Embed HTML/Scripts textarea – for the Footer section.
Make sure to replace the CUSTOM_SLUG with the actual Slug value of the field you’ve created.
<script id="pap_x2s6df8d" src="https://URL_TO_PostAffiliatePro/scripts/trackjs.js" type="text/javascript"></script>
<script type="text/javascript">
slugId = 'CUSTOM_SLUG';
document.querySelector('input[name="' + slugId + '"]').id = slugId;
document.getElementById(slugId).parentNode.parentNode.style.display = "none";
PostAffTracker.setAccountId('Account_ID');
try {
PostAffTracker.track();
setTimeout(function(){PostAffTracker.writeCookieToCustomField(slugId);},1000);
} catch (err) { }
</script>
Create the integration
Still under SamCart Settings go to the Integrations menu and under the Integration Setup tab click the New Integration button. From the dropdown select the Notify URL integration, on the next window name it as you like and insert the following Notify URL.
Make sure to replace the SHOPNAME.samcart.com with the actual URL of your SamCart shop:
https://URL_TO_PostAffiliatePro/plugins/SamCart/samcart.php?accountId=Account_ID&shopUrl=SHOPNAME.samcart.com
Create the rules
Under SamCart Settings > Integrations switch to Global Rules tab and create 2 new rules for triggers Product Purchased and Subscription Charged, in both rules make sure to select the integration you’ve created and the action to Send Notify Url POST.
If you wish to track also refunds and automatically refund the commissions add also a rule for triggers Product Refunded and Subscription Charge Refunded and don’t forget to enable the refund tracking in the plugin configuration in the next step.
Activate the SamCart plugin in PAP
Log in to your Post Affiliate Pro merchant panel and navigate to Configuration > Plugins section and activate the SamCart webhook handling plugin. Once the plugin is activated make sure to configure it, mainly enter your Shop URL as the same value which you’ve added in the previous step.
Add the custom field to products
The last step is to add the custom field you’ve created in previous step to all the products which should be tracked by Post Affiliate Pro. To do this, in your SamCart dashboard navigate to Products and edit each product.
In the product edit view go to the Checkout Design section and scroll down to EDIT YOUR PAGE section and click on the Launch Drag & Drop Builder button. On the next screen go to the Settings > Checkout Form and under Custom Fields section check the checkbox next to the papCookie custom field and save the product by clicking the Publish button at the top of the page.