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). This script needs to be placed on EVERY page on your website, it needs to always be present on the web.
Placing it in a different place may result in empty document.title
in pageView
event).
Please double-check any typos as they may result with Meiro Events not working as expected.
<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>
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 add tracking of the Custom Event and Contact Form.
To learn how to collect Page View events from the Single Page Apps please refer to this article.
To learn more about all events possible to track please refer to this article.