CleverTap is a powerful customer engagement platform that supports push notifications, email, SMS, and in-app messaging—ideal for user segmentation and retargeting. Integrating CleverTap with OpenCart allows merchants to track behavioral events, build dynamic audiences, and automate retargeting campaigns across channels.
🧰 Prerequisites
Requirement | Description |
---|---|
OpenCart 3.x or 4.x | Your eCommerce platform |
GTM Web Container | Installed on all OpenCart pages |
CleverTap Account | With Web SDK credentials and App ID |
Consent Management | Optional but recommended for compliance |
🎯 Targeted Events for Retargeting
Event Name | Trigger Source | Purpose |
---|---|---|
Product Viewed |
Product Detail Page | Browsing intent |
Add to Cart |
Add Button Click | High intent behavior |
Begin Checkout |
Checkout Entry | Funnel drop-off detection |
Purchase |
Order Confirmation | Conversion and LTV analysis |
These will power behavioral segments in CleverTap (e.g., cart abandoners, product viewers with no checkout).
📦 Step 1: Install CleverTap Web SDK via GTM
Create a new GTM tag:
- Tag Type: Custom HTML
- Trigger: All Pages
<script type="text/javascript">
var clevertap = {
event:[],
profile:[],
account:[],
onUserLogin:[],
notifications:[],
privacy:[]
};
clevertap.account.push({"id": "YOUR_ACCOUNT_ID"});
clevertap.privacy.push({optOut: false});
clevertap.privacy.push({useIP: true});
(function () {
var wzrk = document.createElement('script');
wzrk.type = 'text/javascript';
wzrk.async = true;
wzrk.src = 'https://cdn.clevertap.com/js/clevertap.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wzrk, s);
})();
</script>
✅ Replace "YOUR_ACCOUNT_ID"
with your actual CleverTap account ID.
🛒 Step 2: Inject DataLayer Events in OpenCart Templates
A. Product Detail Page (product.twig
)
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
event: 'product_viewed',
product_id: '{{ product_id }}',
product_name: '{{ heading_title }}',
category: '{{ category }}',
price: '{{ price }}'
});
</script>
B. Cart Add Event (add to cart
click handler or cart.twig
)
dataLayer.push({
event: 'add_to_cart',
product_id: '123',
product_name: 'Product Name',
price: 19.99
});
C. Checkout Start (checkout.twig
)
<script>
dataLayer.push({ event: 'begin_checkout' });
</script>
D. Order Success Page (success.twig
)
<script>
dataLayer.push({
event: 'purchase',
transaction_id: '{{ order_id }}',
revenue: {{ order_total }},
currency: '{{ currency }}',
user_email: '{{ email | lower }}',
user_id: '{{ customer_id }}'
});
</script>
🌐 Step 3: Fire CleverTap Events from GTM
A. Product Viewed
Trigger: Custom Event = product_viewed
<script>
clevertap.event.push("Product Viewed", {
"Product ID": "{{DL - product_id}}",
"Product Name": "{{DL - product_name}}",
"Category": "{{DL - category}}",
"Price": "{{DL - price}}"
});
</script>
B. Add to Cart
Trigger: Custom Event = add_to_cart
<script>
clevertap.event.push("Add to Cart", {
"Product ID": "{{DL - product_id}}",
"Price": "{{DL - price}}"
});
</script>
C. Checkout Started
Trigger: Custom Event = begin_checkout
<script>
clevertap.event.push("Begin Checkout", {});
</script>
D. Purchase
Trigger: Custom Event = purchase
<script>
clevertap.event.push("Purchase", {
"Transaction ID": "{{DL - transaction_id}}",
"Revenue": "{{DL - revenue}}",
"Currency": "{{DL - currency}}"
});
</script>
👤 Step 4: Identify Users via Login or Purchase
Use clevertap.onUserLogin
to attribute behavior to specific users:
Trigger: On login or purchase
<script>
clevertap.onUserLogin.push({
"Site": {
"Email": "{{DL - user_email}}",
"Identity": "{{DL - user_id}}"
}
});
</script>
🔐 Step 5: Consent-Aware Tag Execution (Optional)
Wrap your GTM tag or use GTM’s Consent Mode:
<script>
if (window.consent_granted === true) {
clevertap.event.push("Product Viewed", {...});
}
</script>
📊 Step 6: Use CleverTap Segments for Retargeting
Create Behavioral Segments in CleverTap:
- Users who viewed product but didn’t purchase in 3 days
- Users who started checkout but didn’t complete
- Users who made 2+ purchases in last 7 days
Use these segments to trigger:
- Push notifications
- WhatsApp/SMS campaigns
- Email retargeting
- In-app messages (for hybrid OpenCart apps)
🧪 Step 7: QA & Debug
Tool | Purpose |
---|---|
GTM Preview Mode | Ensure correct event triggers |
Clarity Console | Check clevertap.event.push() logs |
CleverTap Dashboard | Verify event ingestion and segment logic |