This guide will walk you through the process of adding a tracking snippet to your Shopify store to monitor sales generated from AI-recommended products using Streamline Connector.
Step 1: Insert the Code Snippet in the <head> Tag
You need to add the following code to the theme.liquid file, right after the <head> tag in your Shopify theme:
<head> {% if template.name == 'product' %} <script> (function() { const urlParams = new URLSearchParams(window.location.search); const sourceCode = urlParams.get('ai-recommended'); if (!sourceCode) return; const formData = new FormData(); formData.append("note", "ai-recommended"); fetch('/cart/update.js', { method: 'POST', body: formData }) .then(response => response.json()) .then(data => console.log('Added source code to cart attributes.', data)); })(); </script> {% endif %}
What Does This Code Do?
Step 2: Modify Recommended Product URLs
To track sales generated from AI recommendations, you need to modify the URLs of your recommended products.
Original URL: https://yourstore.com/product-name
Modified URL: https://yourstore.com/product-name?ai-recommended=true
Step 3: Enable Sales Tracking in Your App
Summary
This setup will allow you to measure the effectiveness of AI recommendations and track sales generated from them directly in your Shopify store.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article