Skip to main content
All CollectionsWhere to Buy
Importing Conversions for Where to Buy
Importing Conversions for Where to Buy

As purchases are made on affiliate networks, they can be tracked as they happen, manually imported via the Dashboard or via SFTP

Michael Fatica avatar
Written by Michael Fatica
Updated over 4 years ago

MetaLocator collects confirmed conversions from retailer affiliate programs to support analytics for Where to Buy.

This conversion data can be imported into MetaLocator in the following ways

  1. Automatically via our existing integrations with affiliate programs like Awin, CJ.com, LinkShare and Amazon

  2. Manually uploaded in the MetaLocator dashboard

  3. Pulled from a MetaLocator-provided SFTP endpoint.

  4. Tracked in real time using the Javascript Tracking API

In methods 2 and 3, the data must be provided in a UTF-8 CSV columnar format according to the provided template.  Download the template.

The data fields are described in the template.  Each row represents a unique purchased item.  

Manually Uploading Conversion Data

To upload conversion data for a retailer, click Retailers, then click name of the retailer.  In the upper right, click Import Conversions as shown below:

Click Upload file... and provide the file in the prescribed format.  

Conversions will be imported, validated and processed.  They will appear in the Retailer Conversion list immediately, but may take up to 24 hours to appear in Analytics.  View the Retailer Conversion list under Retailers,click the "---" button in the Retailer row, then click Conversions.

Providing Conversion Data via SFTP

Some retailers agree to provide data on a regular basis in an automated fashion.  The data should be provided to a MetaLocator-provided SFTP endpoint.  The helpdesk will issue access credentials and connection information securely.

The file should be provided in the format prescribed above.  Each upload should use a unique filename, for example:

Transactions_04_02_2016.csv
Transactions_04_01_2016.csv

Where each file would contain the transactions for the day specified in the filename.

The data file will be imported on a daily basis.  Only one data file should be provided per day.

Usually each data file contains transactions from a single retailer.  If multiple retailers will be represented in a single file, the retailer_id column must be provided and should correspond to the "id" column shown in the MetaLocator dashboard under "Retailers".

Our SFTP system looks for the most recent file in the configured folder and imports the data row by row.  If there are multiple conversion data feeds, each should use its own folder on the SFTP filesystem.  

The helpdesk will configure the SFTP import task automation upon request. 

If subsequent data files will contain duplicate transactions, it is important to provide a transaction_id to avoid duplicate transactions appearing in analytics.

Tracking Conversions in Real Time

To send conversion data to MetaLocator as it occurs our tracking code can be placed or triggered on the goal page of your conversion funnel.   This is typically an order confirmation or "thank you" page displayed only when the user completes the checkout process.

This leverages the Javascript Tracking API to create a conversion in the MetaLocator dashboard.

A complete installation code sample follows.  This should be modified as indicated in the interspersed comments.  The variable values at the top will be provided by your account manager. 

Important Notes: Be careful not to send conversion tracking requests to production during development and testing.  They can not be removed.  Data sent to analyticsbeta.metalocator.com may be removed at any time.

<!--
Start MetaLocator Conversion Tracking Code to be added to an order confirmation page.
This code should be placed or triggered on the conversion "goal" page.
 -->
<script type="text/javascript">
    var _paq = _paq || [];
    //DO NOT MODIFY ABOVE THIS LINE

    //These variables can be configured by the customer.
    var debug = 1; //debug = 1 sends transactions to Analytics BETA, debug = 0 sends transactions to Analytics PRODUCTION.
    var idSite = 1234567890; //Your site ID.  Provided by MetaLocator support.
    var locale = 'en-US';  //Your locale. This should not change and must match the locale in your retailer profile configured in the MetaLocator dashboard.
    var retailerName = 'My Retailer Name'; //your retailer name.  This should not change and must correspond to the name configured in the MetaLocator dashboard.
    var visitorId = 'a73c3cf2988f2030'; //the visitor id passed to your site via the MetaLocator embed. This should be in the format XXXXXXXXXXXXXXXX, as a 16-digit hex visitor key. If empty or invalid, the transaction will be recorded as a new visit.

    //OPTIONAL.  The Currency Code of the incoming transaction.  Not required for USD
    _paq.push(['setCustomDimension',17,'GBP']);

    //DO NOT MODIFY BELOW THIS LINE
    //DO NOT MODIFY BELOW THIS LINE
    _paq.push(['setCustomDimension',3,retailerName ]);
    _paq.push(['setCustomDimension',9,'Affiliate']);
    _paq.push(['setCustomDimension',15,locale]);
    _paq.push(['setCustomDimension',16,locale]);
    var urlAppend = "retailerName=" + retailerName;
    if(typeof(visitorId) !== 'undefined' && visitorId.length > 0){
        visitorId = visitorId.replace(/^vid\_/g,'');
        if(visitorId.length == 16){
            urlAppend += '&cid=' + visitorId;
        }
    }
    if(typeof(debug) !== 'undefined' && debug == 1){
        urlAppend += '&debug=1';
    }
    _paq.push(["appendToTrackingUrl", urlAppend]);
    //DO NOT MODIFY ABOVE THIS LINE
    //DO NOT MODIFY ABOVE THIS LINE

    //In this section, you should trigger each item in the eCommerce order and finally trigger the order as shown below.
    //This example creates an order with two items.
    //API Reference Tracker: https://developer.matomo.org/guides/tracking-javascript-guide
    //API Reference eCommerce: https://matomo.org/docs/ecommerce-analytics/#ecommerce-tracking
    // add the first product to the order
    _paq.push(['addEcommerceItem',
        "12345", // (required) SKU: Product unique identifier
        "Test Product", // (optional, but highly recommended) Product name
        "Test Product Category", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
        18.99, // (required) Product price, always USD
        1 // (optional, defaults to 1) Product quantity
    ]);

    // add the second product to the order
    _paq.push(['addEcommerceItem',
        "678913", // (required) SKU: Product unique identifier
        "Another Product", // (optional, but highly recommended)
        "Test Product Category", // (optional) Product category. You can also specify an array of up to 5 categories eg. ["Books", "New releases", "Biography"]
        48.00, // (required) Product price, always USD
        4 // (optional, defaults to 1) Product quantity
    ]);

    // Push the order to MetaLocator
    _paq.push(['trackEcommerceOrder',
        "TYAOTH12000124", // (required) Unique Order ID
        66.99, // (required) Order Revenue grand total (includes tax, shipping, and subtracted discount)
        66.99, // (optional) Order sub total (excludes shipping)
        5.5, // (optional) Tax amount
        4.5, // (optional) Shipping amount
        false // (optional) Discount offered (set to false for unspecified parameter)
    ]);

    //DO NOT MODIFY BELOW THIS LINE
    //DO NOT MODIFY BELOW THIS LINE
    var siteUrl = 'analytics.metalocator.com';
    if(typeof(debug) !== 'undefined' && debug == 1){
        siteUrl = 'analyticsbeta.metalocator.com';
    }
    _paq.push(['trackPageView']);
    (function() {
        var u="//"+siteUrl+"/";
        _paq.push(['setTrackerUrl', u+'piwik.php']);
        _paq.push(['setSiteId', idSite]);
        var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
        g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
    })();
</script>
<!-- End MetaLocator Conversion Tracking Code -->

Supplying the Visitor ID

When a click occurs on the Where to Buy Interface, the referring link typically includes a "vid" parameter.  This is a unique id that identifies the analytics Visit associated with the click.  The exact syntax of the vid parameter can vary by customer, but is typically provided as 

&vid=a73c3cf2988f2030 

It may also be prefixed in another compound key, such as 

&utm_content=w2b_sku12345_vid:a73c3cf2988f2030 

Regardless of how it is provided to the host Web site, it should be provided as only the 16-digit hexadecimal key in the conversion tracking code above.  This allows us to connect the transaction reported in the conversion tracking code to the session and visitor activity that initiated the conversion.

The methods of collecting, storing and passing the visitor ID vary by host web site and technology preferences.  A typical method is to receive the visitor id on the referring click and store it in a cookie.  Then the cookie value is used as input above.

 

Did this answer your question?