Want to track your SamCart orders in Post Affiliate Pro? We've got you covered.
SamCart and Post Affiliate Pro (PAP) have teamed up to build an integration that allows you to track SamCart orders inside of Post Affiliate Pro.
Follow the steps below to get integrated!
Step #1: Create a Custom Field for Post Affiliate Pro
In order for Post Affiliate Pro to track your SamCart orders, we need to get Post Affiliate Pro's tracking cookie onto your SamCart Product pages. The first step in doing so is creating a Custom Field.
If you're not familiar with how to go about creating Custom Fields inside of SamCart, then head over to this Knowledge Base article. It'll take you through the steps of building one!
Important: For this specific Custom Field, set the Internal Field Name (1) to "papCookie"
Set Checkout Page Label (2) to anything you'd like.
Set Field Type (3) to Text Field.
Make sure Required? and Show In Receipt? are unchecked and click Save (4).
Once the Custom Field is created, add it to all of the Products that you'd like to be tracked by Post Affiliate Pro! To do this, head over to the product you'd like to add it to and click Design + Share, then the Sales Page tab, then the Edit in Builder button. This will take you to the Content Builder - click the Settings tab and then go to the Checkout Form Settings. Here, you can add the custom field and click Publish to save your changes!
Step #2: Add Post Affiliate Pro Tracking Code to SamCart
Now that our Custom Field is created, we need to inject Post Affiliate Pro's tracking cookie onto your SamCart Product pages. To do this, head into your SamCart Dashboard and click into your Settings. In your General Settings, paste the following code into the Embed HTML/Scripts field:
<script id="pap_x2s6df8d" src="http://URL_TO_PostAffiliatePro/scripts/:.js" type="text/javascript"></script><script type="text/javascript">document.getElementById('CUSTOM_SLUG').parentNode.parentNode.style.display = "none";PostAffTracker.setAccountId('Account_ID');try {PostAffTracker.track();setTimeout(function(){PostAffTracker.writeCookieToCustomField('CUSTOM_SLUG');},1000);} catch (err) { }</script>
Important: After you've pasted in the code, replace CUSTOM_SLUG with the Slug from the Custom Field you created in Step #1.
Step #3: Create a Webhook Connection for Post Affiliate Pro
In SamCart, head to the App Marketplace by clicking Apps in your lefthand marketplace navigation bar. The next steps will differ slightly depending on whether you have ever connected a Webhook to SamCart before. Start by searching for "Webhooks" within the App Marketplace - if you have connected a Webhook before, you will see an Open App button on your Webhooks connection. Go ahead and click that button to open the connection!
Once within the Webhooks connection, click on the three dots on the far right side of the screen and then + Connect New App Instance.
This will bring up a popup window where you can choose an App Instance Name and enter a NotifyURL.
The App Instance Name can be whatever you want it to be, in the NotifyURL box you should copy/paste the following NotifyURL:
http://URL_TO_PostAffiliatePro/plugins/SamCart/samcart.php?accountId=Account_ID&shopUrl=SHOPNAME.samcart.com
Click Connect Important: Replace "SHOPNAME" in the NotifyURL above with your SamCart Marketplace name. You can confirm what your SamCart "Shop Name" is by looking at the URL on your marketplace dashboard. For example, the Shop Name in the example below is "ogreachiever" so "SHOPNAME" in the NotifyURL would be replaced with "ogreachiever."
If you have not connected a Webhook within SamCart before, rather than seeing an Open App button within the App Marketplace on Webhooks you will see an Install button. Click the Install button, and you will see a popup containing only a NotifyURL field, but no App Instance Name field. Just fill out the NotifyURL field in the same way described above, and click Connect! The next steps will be the same regardless of which way you connected the Post Affiliate Pro webhook.
Once you have entered the an instance name and the correct NotifyURL, click Connect to save the connection.
Now that you have created a Webhook for Post Affiliate Pro, the last step is to create a rule to make sure that Post Affiliate Pro Webhook knows what action to take.
Make sure that you are on your Post Affiliate Pro instance of within the Webhooks connection, and click on + Add New Rule. This will bring up a side window where you can create a rule to ensure this connection functions as desired!
First, you’ll need to decide if you want this rule to fire for all products (Global Rule) or only specific products that you select (Product Specific Rule). Once you have decided what products to apply this rule to, you will need to select and Action and Trigger.
An action is the functionality available in an Integration you are connected to. A trigger is the event inside of your SamCart Marketplace that tells the connection to send information to the Webhook. In the above example, we used Send NotifyURL POST as the Action and Product Purchased as the trigger as it’s the most common setup.
And that's it! Click Add Rule and SamCart will send an HTTP POST to your Notify URL each time your Product is purchased.
Important: Remember to complete this process for both Product Purchased and Subscription Charged if you would like this rule to fire for every subscription charge, rather than just the first charge.
NOTE: Each application has different Actions available. The following are available on Post Affiliate Pro
- Product Purchased
- Product Refunded
- Product Added to Order
- Subscription Canceled
- Subscription Delinquent
- Subscription Recovered
- Subscription Restarted
- Subscription Charged
- Subscription Charge Failed
- Order Completed
- Upsell Purchased
- Subscription Completed
Step #4: Activate the SamCart plugin in Post Affiliate Pro
Log in to your Post Affiliate Pro merchant panel and navigate to Configuration (1) followed by Plugins (2):
Here, search for SamCart under Plugins and, after SamCart webhook handling appears, hit Activate:
Make sure to match your Shop URL with your SamCart Marketplace URL (https://app.samcart.com/marketplace/yourshopURL).