Metricks Javascript SDK is a customizable Javascript library that our users place on their website to do all the heavy lifting. It handles setting cookies, collecting clicks, conversions, etc., and, of course, sending beacons and tracking pixels of data when events are called.


References

Init


Use this method to initialize metricks-tracker.js

metr(“init”,”your-metricks-api-key”);

Click

This event method will scan the URL for tracking parameters and will track a click, only if the proper parameters exist – that is if the user came through an affiliate referral code. If the click method finds correct tracking parameters, a cookie will be set, and when the client then gets in touch with the conversion code snippet that cookie will get triggered again, and a conversion recorded.

metr(“event”,”detect”);

Customer

Using this method, tracking a new customer is easier. Customers are usually tracked when a visitor, referred by an affiliate signs up for a trial or fills out a lead form.


Then, at a later point, one or more conversions will be created for the customer, e.g., on each successive payment of this customer.

metr(“event”,”customer”, {customer_id: ‘ID-XXXXX’,name: ‘Jane Doe’, email:’jane@example.com’, metadata: {}});

Arguments

customer_id: should be a string and also it’s required. This is the id of your customer and it should be unique for every customer


  • Name: Should be a string and also it’s optional
  • Email: Should be a string and also it’s optional
  • Metadata: Should be an object and also it’s optional. Can be used to store additional data alongside the customer.


Conversion

Using this method track a conversion


This code can always be safely output on the “thank you” page.


This code will only track a conversion when the current visitor was brought in by one of your affiliates, within the specified cookie time.


No external calls will be made for visitors not brought in by an affiliate.

metr(“event”,”conversion”, {order_id: ‘ORD-XXXXX’,customer_id: ‘ID-XXXXX’,amount: 300, currency: ‘USD’, metadata: {}});

Arguments

  • Order_id: Should be a string and is also required. A unique ID for this conversion.
  • Customer_id: Should be a string and also it’s optional. This is the id of your customer that made the conversion.
  • Amount: Should be a string and also it’s optional. The amount for that conversion
  • Currency: Should be the three-letter ISO currency code and also it’s optional.
  • Metadata: Should be an object and also it’s optional. It stores additional data alongside the conversion.


Example:


<script>



    !function(e,t,n,a,c,s,r){e[a]||((c=e[a]=function(){c.process



c.process.apply(c,arguments):c.queue.push(arguments)}).queue=[],c.t=+new Date



(s=t.createElement(n)).async=1,s.src=”https://script.metricks.io/tracker.min.js



t=”+864e5*Math.ceil(new Date/864e5),(r=t.getElementsByTagName(n



[0]).parentNode.insertBefore(s,r))



(window,document,”script”,”metr”),metr(“init”,”YOUR_API_KEY”),metr(“event”,”conversion”,



{order_id: ‘your_order_id’, amount: 25.00, currency: ‘USD’});   



 </script>