Conversion script - GetLinkfire/Integrations GitHub Wiki

Installing the Linkfire conversion script on your webshop will let your shop report back to Linkfire with information about transactions generated by traffic from Linkfire links.

Technical specifications

The lightweight JavaScript-based conversion script will register data if and only if the user has been referred by a Linkfire link.

When the user arrives from a Linkfire link, a token is passed along as a URL parameter and stored as a session cookie to be used when the user completes a transaction. This cookie expires when the session expires.

When the user completes a transaction, a JavaScript function must be called which includes information about the product. If the transaction includes more than one product, the function must be called once for each product.

Implementation guide

To correctly implement the Linkfire conversion script, the implementation must achieve two things:

  • Initialize the Linkfire session
  • Execute transaction

If one or both of these criteria are not met, the conversion script will not work.

Once you have installed the script, write to [email protected] and let us know, supplying the domain your store is on. Then we will whitelist that domain so that traffic to your store from Linkfire will append the URL parameter lf=x, where x is a unique visitor ID that the script will use to recognize sales. If the URL parameter is not present, the script will not fire.

Initialize the Linkfire session

Add the Linkfire conversion script to the page where the user will enter your webshop. This is best achieved by adding it to all pages, including all landing pages, product pages and confirmation pages. The script should be added right before your closing </body> tag.

Code sample:

<!-- Start Linkfire conversion script -->
<script type="text/javascript" src="https://staticcloud.linkfire.com/c1/conversion.js"></script>
<!-- End Linkfire conversion script -->

Execute transaction

When the user completes a transaction, you must call the _trackLF function which receives the following parameters, respectively:

  • Reference (string): An internal identifier for the product, such as UPC.
  • Name (string): The name of the product.
  • Value (number): The order value of the product, specified to 0 if not available.
  • Currency (string): The currency of the order value, as identified by the three-digit currency code.

All parameters are required.

Note that the below code samples include example parameters highlighted in purple. You must replace these parameters with your own.

Code sample:

<!-- Start Linkfire conversion script -->
<script type="text/javascript" src="https://staticcloud.linkfire.com/c1/conversion.js"></script>
<script type="text/javascript">
   window._trackLF('B01BDKNLZG', 'Rihanna - Anti (Standard Edition)', 12.99, 'GBP');
</script>
<!-- End Linkfire conversion script -->

If the transaction includes more than one product, you must call the _trackLF function once for each product.

Code sample:

<!-- Start Linkfire conversion script -->
<script type="text/javascript" src="https://staticcloud.linkfire.com/c1/conversion.js"></script>
<script type="text/javascript">
   window._trackLF('B01BDKNLZG', 'Rihanna - Anti (Standard Edition)', 12.99, 'GBP');
   window._trackLF('B01LXA76QV', 'Starboy [feat. Daft Punk] [Explicit]', 0.99, 'GBP');
</script>
<!-- End Linkfire conversion script -->
⚠️ **GitHub.com Fallback** ⚠️