How to deploy Meiro Events on the website
Setting up DNS records for Meiro Events
Your technical point of contact in Meiro will send you an IP address of the server where the instance of Meiro Events runs just for you.
You will need to set up two DNS record of type A. Let’s take “example.com” as an example domain where your web page runs. And let’s say that you want to deploy Meiro Events to “e.example.com” subdomain. The subdomain can be anything - you can choose, just be consistent. The DNS records for web "example.com" with Meiro Events running at "e.example.com" will need following DNS records:
Type: A, domain: e.example.com, destination: IP address of the ME
Type: A, domain: *.e.example.com, destination: IP address of the ME
How to deploy Meiro Events on your website
Following script needs to be included in the website's head (after <title>
HTML tag)
Placing it in a different place may result in empty document.title
in pageView
event).
<script type="text/javascript">
var domain = "{{COLLECTOR_DOMAIN}}";
var script = document.createElement("script");
var callback = function() {
MeiroEvents.track("outboundLinkClick");
};
script.onload = function() {
MeiroEvents.init(domain);
MeiroEvents.track("pageView");
if (document.readyState === "complete") {
callback();
} else {
window.addEventListener("load", callback);
}
};
script.src = "//sdk." + domain;
script.async = true;
document.head.appendChild(script);
</script>
Please double-check any typos as they may result with Meiro Events not working as expected.
All you need to do is to specify the collector’s domain (for example "collector.meiro.io") and define events you want to track.
The script assumes source will be served from //sdk.{{COLLECTOR_DOMAIN}}
location and it handles events collecting POST requests on {{COLLLECTOR_DOMAIN}}/
API route.
By default, after inserting the above code into your website Meiro Events will collect Outbound Link Click, Page View. It is possible to track the Custom Event and Contact Form but then initial deploy code needs to be manually edited.
To learn more about events please refer to this article.