Step 1: Getting Click ID

Capturing the Click ID (ps_xid)

When a visitor redirects through a partner's link, the may notice two query parameters appended to destination URL: ps_xid and ps_partner_key

  • The value of ps_xid is a unique identifier that PartnerStack uses as a reference to the click event through the Partner's link.
  • The value of ps_partner_key is the base64 encoded partner key, which is the unique identifier of the Partner.

When a visitor converts to a user you'll need to attribute the user to the partner who referred them. To do this you need to associate the ps_xid of the click event with the visitor/user customer_key who clicked the link and send both ps_xid and customer_key to PartnerStack with the conversion event (more on this in "Tracking Conversions" below).

Fetching query parameters
To fetch the ps_xid value from the browser refer to this excellent documentation from the Mozilla Developer Documentation on search parameters.

Mozilla recommends using the URLSearchParams interface to retrieve the value of query parameters in the browser. You can read more on this interface in the Mozilla URLSearchParams documentation.

Example Implementation

The following code illustrates how you may use the URLSearchParams interface to grab the Click ID from the search params.

// get the search string part of the URL
const searchString =;
// create a new URLSearchParams instance
const urlSearchParams = new URLSearchParams(searchString);
// get the ClickID from the search params
const partnerStackClickID = urlSearchParams.get('ps_xid');

After fetching the data, you can store it to the user's session. The exact storage method will depend on your application and use case for tracking.

A common solution would be to store the clickID to a cookie on the user's browser. Be sure that the expiration of this cookie at least matches the duration that the click is valid for attribution. PartnerStack's default is a 90-day, last-click attribution.

If you already have session data tracking technology in place that can hold this Click ID, then we recommend using that existing infrastructure.