Advanced Usage
There are a few advanced ways to use PartnerStackJS if you'd like to make use of them in your front-end application.
Step 1 of the PartnerStackJS install is required to use this
Please ensure you've at least completed Step 1 of the PartnerStackJS install before attempting to use any functionality described here!
Accessing the partner's partner key
When using referral links with PartnerStackJS implemented, the partner key (unique identifier) of the partner who referred a customer is available in three places:
- In the URL when a customer first lands on your website via a referral link. This is Base-64 encoded in the
ps_partner_key
URL query parameter, i.e.?ps_partner_key=Nzg0ZGsdsZWYyMWRi
- In the
growSumoPartnerKey
cookie value on your domain. This value is already Base-64 decoded for you. - In the
growsumo.data
object, asgrowsumo.data.ps_partner_key
. This value is already Base64-decoded for you.
Call a function immediately after PartnerStackJS has loaded
If you want to call a function immediately after PartnerStackJS has loaded, simply name the function growsumoInit()
<script>
function growsumoInit() {
console.log("Hello world");
}
</script>
Combining PartnerStackJS with the S2S Conversion API
If you're in the situation where you'd rather send customer signup information via your website's back-end, but still want the benefit of PartnerStack link tracking, combining PartnerStackJS and our S2S Conversion API may work well for you! This can work in scenarios where:
- Your customer's unique identifier is generated in your back-end and isn't available to your front-end readily for PartnerStackJS to make use of
- You're not able to add event listeners to your form or access the DOM elements you need for a PartnerStackJS
createSignup
call as described in Step 2: Track Signup Events
Heads up!
Implementing PartnerStackJS this way will require someone to make changes to your site's back-end code, which will involve:
- Accessing the
ps_partner_key
cookie value we populate, via your back-end- Adding an HTTP call to our REST API endpoints (specifically the S2S Conversion API)
This may not work in all environments and any code provided is an example.
After implementing Step 1 of the PartnerStackJS install, whenever a customer accesses your site via a partner's referral link, the ps_xid
value will be populated as a 1st party cookie on your domain. If your site's backend has access to cookies (i.e. a sign-up form makes a POST
request to an endpoint on your back-end and cookies are available in the request data), you can:
- Extract the ps_xid from the
growsumo
cookie. This value is the unique identifier that PartnerStack uses as a reference to the click event through the Partner's link. - Use this px_xid in a call to the S2S Conversion API endpoint:
POST https://partnerlinks.io/conversion/xid
. Note: You will need to authenticate this API call via Bearer Token authentication. The token is found in the PartnerStack dashboard here: https://app.partnerstack.com/settings/integrations
A call to this endpoint requires the following required data in the body:
Request Body Parameter | Description |
---|---|
xid | This value is the unique identifier that PartnerStack uses as a reference to the click event through the Partner's link. (ps_xid value from the cookie) |
customer_key | A unique identifier for the customer (e.g their email, or an ID used in your billing system) |
List of additional data you can provide in this conversion endpoint is outlined here: https://docs.partnerstack.com/docs/step-3-tracking-conversions.
An example of this S2S Conversion request is shown below. In this case, the unique customer key is a UUID that's shared across the application, but your selection of a customer key may vary!
curl --location --request POST 'https://partnerlinks.io/conversion/xid' \
--header 'Authorization: Bearer <TOKEN>' \
--header 'Content-Type: application/json' \
--data-raw '{
"customer_key": "fe955429-0fe2-42c2-8eb5-a7d6495d4a7e",
"xid": "<XID>",
"email": "example@email.com",
"name": "Example Customer Name",
"origin": "acme.com",
"ip_address": "198.51.100.42",
"user_agent": "Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion",
"external_type": "xyz",
"sub_ids": [
"chskadycgbchb",
"sdjvkhckjsckd"
]
}'
Refer to the following S2S Conversion API Tracking Guide for more information for additional information and possible response codes: https://docs.partnerstack.com/docs/step-3-tracking-conversions.
Updated 10 days ago