π Shopify Affiliate Integration Setup
Connect wolfbeans.com orders to CareZiaSpace affiliate tracking
π How the Full Flow Works
Affiliate shares link
careziaspace.com/?ref=WOLF42XK
Visitor lands on CareZiaSpace
ref code saved to browser storage
Visitor clicks "Shop Coffee"
wolfbeans.com/?ref=WOLF42XK
Shopify JS captures ref
Saved as cart attribute "affiliate_ref"
Order is placed
Shopify fires webhook to Base44
Commission recorded
40% added to affiliate earnings + WolfCoin log
How to add this to Shopify:
1. Go to wolfbeans.com Shopify Admin β Online Store β Themes
2. Click "Edit code" on your active theme
3. Open Layout β theme.liquid
4. Paste the snippet just before the closing </body> tag
5. Click Save
<!-- CareZiaSpace Affiliate Tracking β Paste in theme.liquid before </body> -->
<script>
(function() {
// Capture ?ref= from URL and store in cookie + localStorage
var urlParams = new URLSearchParams(window.location.search);
var ref = urlParams.get('ref');
if (ref) {
// Store for 30 days
var expires = new Date();
expires.setDate(expires.getDate() + 30);
document.cookie = 'affiliate_ref=' + ref + '; expires=' + expires.toUTCString() + '; path=/';
localStorage.setItem('affiliate_ref', ref);
}
// On cart page / checkout β inject ref into cart attributes
function getAffiliateRef() {
var cookie = document.cookie.split(';').find(function(c) { return c.trim().startsWith('affiliate_ref='); });
if (cookie) return cookie.split('=')[1];
return localStorage.getItem('affiliate_ref');
}
// Add ref to cart note attributes via AJAX
var storedRef = getAffiliateRef();
if (storedRef) {
fetch('/cart/update.js', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
attributes: { affiliate_ref: storedRef }
})
}).catch(function() {});
}
})();
</script>