As an alternative to installing the conversion tracker on your site, you can instead use Friendbuy's REST API to generate conversions by making a POST request to the purchases endpoint.

When a referred visitor lands on your site, follow these steps to use the REST API to generate a conversion:

  1. Several url parameters will be present when a referred visitor lands on your site after clicking a referral link.  One parameter, fbuy_ref_code, provides the information needed to associate a referral purchase with a share or personal url. Capture the fbuy_ref_code parameter store it with the user using which ever mechanism you prefer. For example, you could store fbuy_ref_code value in a cookie or as part of the user session.

  2. Whenever a purchase is made, check to see if the user has an fbuy_ref_code associated with them.

  3. If the user has an fbuy_ref_code value, make a POST request to the purchases endpoint using the value captured as the referral code in the request.  The POST body will look like this:

    "order": { "id": "281", "amount": 795.00, "email": "", "new_customer": true },
    "referral_code": "1reN"

The call to the purchases endpoint has the following requirements:

  • A value must be present for both order and referral_code.

  • customer and products data can be provided, see purchases endpoint for more details.

The response may be one of the following

Did this answer your question?