API Reference

Step One: Integrate Click Tracking

Add the one-line script below to your main site template just before the closing </body> tag. This script must be on every page, as it takes the tracking URL and turns it into a first-party cookie.

<script defer src="https://static.shopmy.us/Affiliates/sms_aff_clicktrack.js"></script>

Step Two: Integrate Order Tracking

Add the following script to your order confirmation page. Replace placeholders (marked with ***) with actual checkout system values

<script>
  const cookies = document.cookie.split(';').reduce((res, cookie) => ({ ...res, [(cookie.split('=')[0] || '').trim()]: (cookie.split('=')[1] || '').trim() }), {});
  const { sms_click_id, sms_click_time } = cookies;
  const code = `***THE CODE USED AT CHECKOUT***`;
  fetch(`https://api.shopmy.us/api/order_confirmation`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      orderAmount: `***THE ORDER TOTAL***`,
      orderId: `***THE ORDER ID***`,
      clickId: sms_click_id,
      currency: `***THE ISO 4217 CURRENCY CODE, EX: USD***`,
      is_returning_customer: false,
      page_url: window.location.href,
      code
    })
  })
  .then(r => {
    if (!r.ok) throw new Error('Invalid order request sent');
    r.json();
  })
  .then(() => {
    const now = new Date();
    document.cookie = `sms_click_id=;expires=${now.toUTCString()};path=/;`;
    document.cookie = `sms_click_time=;expires=${now.toUTCString()};path=/;`;
  })
  .catch(() => {
    // ignore the error
  });
</script>

Step Three: Handle Order Updates / Cancellations

Through MIVA you are able to create a webhook that will notify us when an order is updated or cancelled. This can be done through your admin dashboard.

  1. Login to your MIVA admin dashboard and navigate to order workflows.
  2. Create a new workflow and name it "ShopMyShelf Order Cancellation"
  3. Add a new action to the workflow and select "Webhook"
  4. Configure the webhook trigger to be Order Status Updated
  5. Configure the webhook action to be "POST" and paste the below URL into the URL field with your unique Brand Developer Key
    1. https://api.shopmy.us/api/AffiliateWebhooks/miva/order/statusUpdate/<YOUR_DEVELOPER_KEY>
      

Step Four: Request Testing

Contact your Brand Success Manager to place a test order and test the integration end-to-end. We will communicate with you any test order IDs we place so they can be cancelled after the integration is verified.


📘

By adding our integration code to your site, you are agreeing to the terms of the ShopMy affiliate network. Please review these terms here.