Direct Code Integration to a Custom Online Store
Use case: Your custom online store does not use GTM or you prefer embedding the SDK directly.
Integration Steps
Step 1: Load the Pixel SDK
Copy and paste the following script into your website globally.
(function (w, d) {
var u = "https://cdn-static.mintegral.com/sdk/pixel.js";
if (w.mintegralPixel) return;
var s = (w.mintegralPixel = function () {
s.performOperation
? s.performOperation.apply(s, arguments)
: s.operationQueue.push(arguments);
});
s.operationQueue = [];
var f = d.getElementsByTagName("script")[0],
e = d.createElement("script");
e.async = !0;
e.src = u;
f.parentNode.insertBefore(e, f);
})(window, document);
mintegralPixel("init", {
setupType: 1 // 1 - self-built website
});
Step 2: Reporting MTG Official Events
mintegralPixel("track", {
"type": <event_name>,
"data": <event_data>
});
Parameters
Name |
Type | Description |
type | string |
The name of event. See Standard Events and Objects for available events. |
data | object |
The data of event. See Standard Events and Objects for available events. |
Enhanced User Identification (Recommended)
The Mintegral Pixel sets a first-party cookie _mtgtrk
to identify users. This cookie is automatically sent in every request to your website. To enhance user identification, Mintegral strongly recommends that you perform the following on the back-end of your site:
Whenever you see the cookie _mtgtrk
in an HTTP request, set the HTTP response so that it includes a header which sets a new first-party HTTP cookie mtgtrk
(remove the underscore from the beginning) with a one-year expiration date.
- The value of this new cookie should be exactly the same as the value of the corresponding
_mtgtrk
cookie in the incoming request - The domain for the cookie should be your site, prefixed with a period
- Example: if your site is
yoursite.com
, the domain attribute should be.yoursite.com
. - ⚠️ Note:
"www"
should not be included here
- Example: if your site is
- The path for the cookie should be
/
- Do not set the cookie to be
HttpOnly
Example:
If your site receives an HTTP request where the value of the _mtgtrk
cookie is:
exxxxxxx-8xxx-4xxx-bxxx-1xxxxxxxxxxx
Then your HTTP response should include:
Set-Cookie: mtgtrk=exxxxxxx-8xxx-4xxx-bxxx-1xxxxxxxxxxx;
Expires=«One Year from Today»; Domain=«.yoursite.com»; Path=/; SameSite=Lax;