MarkTag Setup Guide
After generating a MarkTag through the API, this guide shows you how to implement the tracking code on websites.
Understanding Your MarkTag Response
When you generate a MarkTag, you'll receive different responses based on the type:
Client-Side Response
json
{
"tagId": "client-ABC123",
"status": "active",
"type": "client-side"
}Server-Side Response
json
{
"tagId": "server-XYZ789",
"status": "inactive",
"type": "server-side",
"record": {
"type": "CNAME",
"name": "mtag",
"value": "mtag.markopolo.ai"
}
}Installing the Tracking Code
Step 1: Extract Your Parameters
From the API response, identify:
- tagId: The unique identifier for the MarkTag
- domain:
- Client-side:
mtag.markopolo.ai - Server-side:
mtag.{merchant-domain}.com(after DNS setup) - Preverified:
mtag.{your-platform}.com
- Client-side:
Step 2: Add to Website
Add this code to the <head> section of every page:
html
<script>
window.mtrem = window.mtrem || [];
function mtag() { mtrem.push(arguments) }
mtag("init", "https://DOMAIN?tagId=TAG_ID", {"consent": true});
</script>
<script async type="text/javascript" src="https://DOMAIN/script"></script>Replace:
DOMAINwith the appropriate domainTAG_IDwith your tagId from the API response
Step 3: Verify Installation
Open the browser console and check:
javascript
typeof mtag === 'function' // Should return trueImplementation by Type
Client-Side (Instant)
html
<script>
window.mtrem = window.mtrem || [];
function mtag() { mtrem.push(arguments) }
mtag("init", "https://mtag.markopolo.ai?tagId=client-ABC123", {"consent": true});
</script>
<script async type="text/javascript" src="https://mtag.markopolo.ai/script"></script>No DNS setup required - Works immediately after generation.
Server-Side (After DNS Verification)
First, merchant must add CNAME record, then verify via API, then:
html
<script>
window.mtrem = window.mtrem || [];
function mtag() { mtrem.push(arguments) }
mtag("init", "https://mtag.merchantdomain.com?tagId=server-XYZ789", {"consent": true});
</script>
<script async type="text/javascript" src="https://mtag.merchantdomain.com/script"></script>Requires DNS setup - Only works after verification.
Preverified (Platform Integration)
html
<script>
window.mtrem = window.mtrem || [];
function mtag() { mtrem.push(arguments) }
mtag("init", "https://mtag.yourplatform.com?tagId=server-DEF456", {"consent": true});
</script>
<script async type="text/javascript" src="https://mtag.yourplatform.com/script"></script>Pre-configured - Works immediately if you have preverified access.
Tracking Events
Once installed, use the global mtag function to track events:
javascript
// Page view (automatic on init)
mtag('event', 'PageView');
// Custom event
mtag('event', 'Purchase', {
value: 99.99,
currency: 'USD',
products: [{
id: 'SKU-123',
name: 'Product Name',
price: 99.99,
quantity: 1
}]
});Mobile apps
For native mobile apps:
- Use the React Native SDK or Flutter SDK with the same MarkTag (same
tagId/ tag value from your API). - Default events (such as those automatically tracked on the web) are not supported in the mobile SDKs. All events must be logged explicitly in the app—see React Native Usage and Flutter Usage.
Common Issues
Script Not Loading
- Verify the domain is correct
- Check for ad blockers (client-side)
- Ensure DNS is configured (server-side)
Events Not Tracking
- Confirm
mtagis defined:typeof mtag === 'function' - Check browser console for errors
- Verify tagId is correct
DNS Verification Failed (Server-Side Only)
- Wait for DNS propagation (5-30 minutes)
- Verify CNAME record is correct
- Use
nslookup mtag.domain.comto check
Next Steps
- Track Ecommerce Events - Essential events for online stores
- Query Events API - Retrieve tracked data
- Web SDK Documentation - Advanced tracking features