This guide walks you through integrating Partnero tracking into your website using client-side JavaScript. Ideal for simple setups where you want to track sign-ups and sales directly from the browser.
Before proceeding, you should have a program created on Partnero. If you haven’t created one yet, refer to the Knowledge Base for guidance.
Step 1: Install PartneroJS
Install the PartneroJS snippet to track referral visits and attribute sign-ups to the correct partners.
Get your snippet
Log in to Partnero
Go to Programs and select your program
Navigate to Integration in the sidebar
Copy the PartneroJS snippet
Install the snippet
Paste the snippet into your website’s HTML just before the closing </head> tag: <!-- PartneroJS -->
< 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 PartneroJS -->
When a visitor arrives via a referral URL (e.g., yoursite.com?via=PARTNER_KEY), the script creates a first-party cookie to store the referral:
partnero_partner for affiliate programs
partnero_referral for refer-a-friend programs
When the visitor signs up or makes a purchase, the cookie is used to attribute them to the correct partner.
Step 2: Sign-up Tracking
Notify Partnero when a new customer signs up to attribute them to the referring partner.
The simplest option - automatically captures sign-ups from standard HTML forms:
< script >
po ( 'integration' , 'universal' , null );
</ script >
Add this at the bottom of pages with signup forms. It detects form submissions and creates customers using the submitted name and email.
JavaScript Sign-up Tracking
For more control, use the JavaScript method directly after a successful sign-up:
You don’t need to pass the partner key manually. PartneroJS automatically reads it from the partnero_partner cookie when present on the page.
po ( 'customers' , 'signup' , {
data: {
key: 'customer_123456' , // Unique customer ID or email
name: 'John' ,
email: '[email protected] '
}
});
po ( 'customers' , 'signup' , {
data: {
key: 'customer_123456' ,
name: 'John' ,
email: '[email protected] ' ,
partner: {
key: 'PARTNER_REFERRAL_KEY' // Optional: explicitly set partner
}
}
});
Parameters
Parameter Type Required Description keystring Yes Unique customer identifier (account ID or email recommended) namestring No Customer’s first name (max 100 characters) surnamestring No Customer’s last name (max 100 characters) emailstring No Customer’s email address (max 255 characters) tagsarray No Array of tag names to assign to the customer partner.keystring No Partner’s referral key (auto-detected from partnero_partner cookie if not provided)
Complete Example
< html >
< head >
< title > Sign Up </ title >
<!-- PartneroJS -->
< 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' , 'YOUR_PROGRAM_ID' , 'load' );
</ script >
</ head >
< body >
< form id = "signup-form" >
< input type = "text" name = "name" placeholder = "Your name" />
< input type = "email" name = "email" placeholder = "Your email" required />
< input type = "password" name = "password" placeholder = "Password" required />
< button type = "submit" > Sign Up </ button >
</ form >
< script >
document . getElementById ( 'signup-form' ). addEventListener ( 'submit' , function ( event ) {
event . preventDefault ();
const name = this . querySelector ( 'input[name="name"]' ). value ;
const email = this . querySelector ( 'input[name="email"]' ). value ;
if ( email ) {
po ( 'customers' , 'signup' , {
data: {
key: email ,
name: name ,
email: email
}
});
}
// Continue with your form submission logic
});
</ script >
</ body >
</ html >
Step 3: Sales Tracking
Track purchases to reward partners according to your program’s commission structure.
Prefer automatic tracking? Connect your payment processor for automatic transaction tracking without writing code:
Stripe - Payments, subscriptions, and refunds
Paddle - Checkout and subscription events
Chargebee - Subscription billing
Set up integrations in Program Settings → Integrations .
JavaScript transaction tracking is disabled by default for security reasons. Enable it on your program’s Integration page, or use the API or payment gateway integrations instead.
PartneroJS automatically attributes transactions to the correct partner using the partnero_partner cookie—no need to pass the partner key manually.
Execute this script immediately after a successful sale:
po ( 'transactions' , 'create' , {
data: {
key: 'transaction_123' ,
amount: 99.99 ,
amount_units: 'usd' ,
customer: {
key: 'customer_123456'
}
}
});
po ( 'transactions' , 'create' , {
data: {
key: 'transaction_123' ,
amount: 99.99 ,
amount_units: 'usd' ,
product_id: 'prod_123' ,
product_type: 'monthly' ,
customer: {
key: 'customer_123456'
}
}
});
po ( 'transactions' , 'create' , {
data: {
key: 'transaction_123' ,
amount: 99.99 ,
amount_units: 'usd' ,
customer: {
key: 'customer_123456'
}
},
options: {
create_customer: true
}
});
Parameters
Parameter Type Required Description keystring No Unique transaction ID (recommended for refund handling) amountnumber Yes Transaction amount amount_unitsstring No Currency code (e.g., usd, eur, gbp) product_idstring No Product ID for advanced commission rules product_typestring No Product type/category for commission rules customer.keystring Yes Customer identifier (from sign-up) options.create_customerboolean No Create customer if not exists and attach transaction
Next Steps
API Integration For server-side tracking with full security
Stripe Integration Automatic transaction tracking with Stripe