WinRed integration
WinRed is the official secure payments technology designed to help GOP candidates and committees win across the US. WinRed Allows Donors to Donate Quickly and Securely to the Candidates and Causes They Support.
Integration with WinRed is done via webhook and by passing visitor ID to WinRed links as bundler_id parameter.
1. Configure webhook in WinRed
When you log in to your WinRed portal go to Utilities->Integrations, click on Add Integration button and select Webhook. Set the Endpoint URL to the following:
https://URL_TO_PostAffiliatePro/plugins/WinRed/winred.php
Proceed to configure Donation Webhook Fields and make sure you include these JSON Payload Keys and Values:
- subscription_id => Subscription ID
- recurring => Recurring
- first_subscribed => First Subscribed
- status => Status
- bundler_id => Bundler
- referer => Referer
- user_agent => User Agent
- order_id => UID
- total_cost => Net
- amount_refunded => Amount Refunded
- product_id => Product Name
Keys need to be set as specified above but the values for the last 4 pairs, which are not highlighted in bold, can be set arbitrarily based on what you want to track. You can also pass additional key value pairs which can then be configured to save into the Extra Data fields of the commissions in configuration of the tracking plugin.
2. Configure the tracking plugin
In your Post Affiliate Pro merchant panel go to Configuration->Plugins activate the WinRed webhook handling plugin and configure it by following the instructions by each of the options.
3. Include the following code on pages with WinRed links
Include the following tracking code in the footer of your website where you have your WinRed links embedded. The purpose of the code is to track clicks on affiliate links and append our tracking ID to all WinRed links as bundler_id parameter.
<script type="text/javascript">
var a={b:document.querySelectorAll('a[href*="winred.com/"]'),c:function(){let d=document.createElement('script');d.type='text/javascript',d.id='r',d.src='https://URL_TO_PostAffiliatePro/scripts/trackjs.js',d.onload=function(){a.e()},d.onerror=function(){a.f()},document.body.appendChild(d)},g:function(){for(i=0;i<a.b.length;i++)a.b[i].id='p'},h(n){c={},document.cookie.split(';').forEach(function(el){let[k,v]=el.split('=');c[k.trim()]=v});return c[n]},e(){try{PostAffTracker.setAccountId('default1'),PostAffTracker.track(),PostAffTracker.writeCookieToLink('p','bundler_id','',!1)}catch(err){a.f()}},f(){const j=new URLSearchParams(window.location.search);let v=j.get('visitorId'),x=j.get('a_aid');null!==v&&32===v.length?(document.cookie='PAPVisitorId='+v+'; max-age=31536000; path=/; SameSite=Lax',localStorage.setItem('PAPVisitorId',v)):v=localStorage.getItem('PAPVisitorId')||a.h('PAPVisitorId'),null!==x?(document.cookie='PAPAffiliateId='+x+'; max-age=31536000; path=/; SameSite=Lax',localStorage.setItem('PAPAffiliateId',x)):x=localStorage.getItem('PAPAffiliateId')||a.h('PAPAffiliateId');let t=v??x;if(t)for(i=0;i<a.b.length;i++){let u=new URL(a.b[i].href);u.searchParams.set('bundler_id',t),a.b[i].href=u.toString()}}};a.g(),a.c();
</script>