Sync Purchase Data

How to submit your purchase data to MIME

One way MIME's AI learns and continues to get smarter is by getting input from customers all around the world after they purchase a recommended product.

Purchase data is sent from your website at checkout to MIME via a webhook.

Custom Webhook Method

Documentation is available here: https://mimepublic.docs.apiary.io/#reference/0/webhooks-purchase/save-a-user-purchase

  1. Get your staging credentials from MIME and set as staging environment variables

  2. Integrate the webhook at checkout

  3. Test on staging and confirm the purchase data saves to MIME correctly

  4. Prepare for production; add your production keys from MIME to environment variables

For more information please contact onboarding@getmime.com to get your API Client Key and Secret.

Google Tag Manager Integration Method

First, define the URL where you can send the purchase data. Store it as a custom GTM variable: mime - endpoint and reference it in the image pixel src (below):

//Custom GTM variable "mime-endpoint"
<script>
function() {

    'use strict';

    var baseUrl = 'https://api.getmime.com/webhooks/updatePurchaseGET/?';

    var clientCampaign = {{Environment Name}} ? 'test' : 'foundation-finder';

    var products = '{{list of products, comma delimited}}' ;


    return baseUrl

    + 'signature={{signature}}'

    + '&referring_host_url={{domain}}&client_user={{client_key}}'

    + '&client_campaign=' + clientCampaign

    + '&mimecid=' + {{cookie - mime_cid}}

    + '&mimerid=' + {{cookie - mime_rid}} 

    + '&product_ids=' + products

    + '&update_type=SALE&purchased_timestamp=' + {{cj - UTC Timestamp}}

    + '&email={{customer_email}}';

}
</script>

You'll store the referring *mime_cid* and *mime_rid* in a cookie when the customer comes back to your PDP with the correct shade pre-selected.

<script>
  (function () {
  // 7 days
  var maxAge = 604800;
  var cookieParams = 'secure;samesite;path=/';
  var mimeParams = [
    {'a':'mime_rid', 'b': {{url - query - mime - mime_rid}} },
    {'a':'mime_cid', 'b':{{url - query - mime - mime_cid}} },
    {'a':'result_id', 'b':{{url - query - mime - result_id}} }
  ];
  for (var i = 0; i < mimeParams.length; i++) {
    if (mimeParams[i].b !== undefined) {
      document.cookie = mimeParams[i].a + '='+ mimeParams[i].b +';max-age='+ maxAge + ';' + cookieParams
    }
  }
  })();
</script>

Then on the purchase conversion event, trigger a custom image pixel using your custom GTM variable mime-endpoint as defined above. This sends the information via URL GET request to our servers:

<img height="1" width="1" src="{{mime-endpoint}} />

Shopify Webhooks Method

  1. Log in to your Shopify store and go to this link: {YOUR STORE NAME HERE}.myshopify.com/admin/settings/notifications

  2. Go to the Webhooks section

  3. Create a new Webhook

  4. Choose "Order Creation" for the Event

  5. Choose "JSON" as the Format

  6. Enter this URL into the URL field: https://api.getmime.com/webhooks/updatePurchaseShopify/?client_user={YOUR CLIENT ID HERE}

  7. Choose 2021-07 as the Webhook API Version

  8. Click Save

  9. There should be a code provided which is used to verify the integrity of the Webhook. This code will look like a long string of random letters and numbers. Please share that code with your MIME onboarding team member.

Last updated