Custom Integration: E-Commerce
Want to use Metisa even though your app is not built with any of the plugin-supported platforms? Use this article to set up your site to take full advantage of Metisa's recommendation engine for store.
To integrate your custom store with Metisa:
- You must have a Metisa account. Custom integrations are available to all Metisa users, whether you're on a Free or Paid tier.
- You must have basic technical know-how. You will be fine if you're comfortable navigating files and inserting code blocks, and some light coding with guidance.
- Your store must use a template rendering engine. EJS, Liquid, Django are some examples. This installation rides on your store's template tags to obtain data to send to Metisa servers.
Recommendations are made based on machine learning algorithms that feed on your store data like products, orders, and customers.
We therefore need a way for your store to automatically send such data to Metisa, so that over time (3-7 days depending on site traffic), Metisa will learn enough about your customers' individual preferences to start providing good recommendations that get more accurate with time.
There are two main steps to installing the scripts that enable custom integration.
Metisa requires v1.5+ jQuery, a library used frequently by web developers. Please make sure jQuery is available.
Add this to your base template file if your site uses an older version of jQuery or does not use it at all. (Note: adding this code block when your site already loads jQuery has a very slim chance of breaking your site due to differences between versions.)
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
TIP: Your base template filename will vary depending on how your developer named it.
Common names are index and theme, with file extensions like .html, .erb, .ejs, .liquid (eg. index.ejs or theme.liquid)
Once jQuery is available, paste the following script to the same file below jQuery. This will load the Metisa script that is needed to send and receive data to/from Metisa.
TIP: This step can be tricky, especially when trying to match data to the right fields.
Refer to our examples to see how this is implemented for sample stores.
Product data is sent to the Metisa server every time a customer browses a specific product on your store. That is why the product template file is where you should place this code snippet that sends data about that specific product to Metisa.
With each page load, the product information is created or updated in the Metisa database.
DETAIL: Note the difference between "product" and "variant". A product can have none or many variants. When a product has no variants,
variantsmust still have one object representing the product itself.
variant_namein such a case should be
Likewise for order data, you can embed a code snippet to your order checkout template so that whenever an order is finalized it will be sent to Metisa servers.
DETAIL: If your store supports "guest" checkouts, you may not generate a
customer_idand it can be left as
null. Metisa will then switch strategy to use email to identify guest customers.
To embed a recommendation block on your site, you need to decide which widget(s) you want and where they should show up.
- Log in to your Metisa dashboard
- Click on Widgets on the left side bar
- Preview the various widgets
Once you have chosen a spot on a specific page to embed, copy and paste your customized code from your Metisa account.
To get your customized code for the widget:
- Select the Widget you want to embed (eg. Things you may like)
- Click on Activate Now -> Customize your options -> Click Next
- Copy and paste the code from the page into your template file
If your code is embedded correctly, save the changes and you should see your recommendation widget appearing on your site immediately.
IMPORTANT: If you had just installed the code from the Install section, your recommendations may not be ready yet, in which case you will see an empty widget with no products.
In this situation, we recommend you to check back again in a few hours (the more traffic your store receives, the shorter the wait) before trying to embed recommendations on your site.
If any of this is overwhelming and you need help, please don't hesitate to reach us at email@example.com any time. One of our engineers will be happy to assist you in the setup process.