Tracking with JavaScript
Partnero simplifies the process of integrating and managing affiliate programs with its easy-to-use platform. This guide will walk you through the steps of integrating an Affiliate program into your stack using simple front-end integration.
Please note that before proceeding with the integration, you should already have an affiliate program created on Partnero. If you haven't created a program yet, refer to our guide on creating an affiliate program.
Visitors tracking
Visitor tracking enables the identification of referral visits to your website.
For accurate tracking and attribution of referral visits and signups to the appropriate partners, you need to install the Partnero Universal script on your website as custom code.
To find the snippet, please follow these steps:
- Log in to Partnero
- Go to Programs
- Choose your Program if there is more than one
- On the left sidebar, go to Integration under Program
- Copy the Partnero Universal snippet
Once you have your unique Partnero Universal javascript snippet copied, paste it into your website’s HTML just before the closing of the </head>
tag.
Example of Partnero Universal
<!-- Partnero Universal -->
<script>
(function(p,t,n,e,r,o){ p['__partnerObject']=r;function f(){
var c={ a:arguments,q:[]};var r=this.push(c);return "number"!=typeof r?r:f.bind(c.q);}
f.q=f.q||[];p[r]=p[r]||f.bind(f.q);p[r].q=p[r].q||f.q;o=t.createElement(n);
var _=t.getElementsByTagName(n)[0];o.async=1;o.src=e+'?v'+(~~(new Date().getTime()/1e6));
_.parentNode.insertBefore(o,_);})(window, document, 'script', 'https://app.partnero.com/js/universal.js', 'po');
po('settings', 'assets_host', 'https://assets.partnero.com');
po('program', 'PUBLIC_PROGRAM_ID', 'load');
</script>
<!-- End Partnero Universal -->
Sign-ups tracking
The second step is to notify Partnero about new user sign-ups to keep track of referrals from affiliate partners.
Immediately after a user successfully signs up, make sure to run this script to ensure proper tracking.
<script>
po('customers',
'signup', {
data: {
key: 'customer_123456', // or email address
name: 'John',
email: 'john.doe@partnero.com'
}
}
);
</script>
<script>
po('customers',
'signup', {
data: {
key: 'customer_123456', // or email address
name: 'John',
email: 'john.doe@partnero.com',
partner: {
key: '{UNIQUE_PARTNER_KEY}'
}
}
}
);
</script>
Customers referred by partners are automatically identified when their data matches information stored in the partnero_partner
or patnero_referral
(Refer-a-friend program) cookies, which is set by our Partnero Universal script. This process is handled by the Partnero Universal script, ensuring accurate recognition of referred customers.
Request parameters
Parameters | Type | Required | Limitations | Details |
---|---|---|---|---|
key | string | yes | Can be anything, but we recommend using an account ID or customer's email address. This will be required when creating transactions for the customer. | |
name | string | optional | The name of the customer. | |
email | string | optional | The email of the customer. | |
partner | object[] | optional | ||
partner.key | string | optional | Partner's key from partnero_partner or patnero_referral cookies. If a partner or referring customer is not specified, Patnero Universal will automatically attempt to identify and include this information from the URL or cookies. |
Sales tracking
The following step of the integration is sending data about sales. When any user makes a purchase, it is recommended to inform Partnero about it.
Please ensure to execute this script immediately following a successful sale.
<script>
po('transactions', 'create', {
data: {
key: 'transaction_123',
amount: 99.99,
amount_units: 'usd',
product_id: 'prod_123', // optional
product_type: 'monthly', // optional
customer: {
key: 'customer_123456'
}
}
});
</script>
<script>
po('transactions', 'create', {
data: {
key: 'transaction_123',
amount: 99.99,
amount_units: 'usd',
product_id: 'prod_123', // optional
product_type: 'monthly', // optional
customer: {
key: 'customer_123456'
}
},
options: {
create_customer: true // Use this option to create a customer and a transaction at the same time
}
});
</script>
Request parameters
Parameters | Type | Required | Limitations | Details |
---|---|---|---|---|
key | string | optional | Payment ID. It is not required but recommended (must be unique). We recommend using a payment ID on your system. Later can be used to refund/delete transactions. | |
amount | string | yes | A full amount of the purchase. Partnero will calculate partner's reward based on program settings. | |
amount_units | string | optional | ||
action | string | optional | For example, sale . | |
customer | object[] | yes | ||
customer.key | string | yes | The same value from customer creation (if customer exists). | |
customer.email | string | optional | ||
customer.name | string | optional | ||
product_id | string | optional | Product ID. It is used to for advanced commmission calculation. | |
product_type | string | optional | Product type or category. It is used to for advanced commmission calculation. | |
options | object[] | optional | ||
options.create_customer | string | optional | true or false | Use this option to create a customer and a transaction at the same time. |