Initializing Ematic.js
If your website is using requireJS, move to the requireJS part in this page that is built specifically for it.
To use Bye-iQ, copy and paste the following JavaScript snippet into your website templates so that it appears before the closing </head>
tag:
<script>
(function(i,s,o,g,r,a,m){i['EmaticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//api.ematicsolutions.com/v1/ematic.min.js','ematics');
var opt = {
email: "<email of the user logged in if applicable>",
country_iso: "<country>",
currency_iso: "<currency>",
language_iso: "<language>"
}
//initialize
ematics("create", ematicApikey, opt);
</script>
When the code runs, it asynchronously loads the ematic.min.js library onto the page, and then creates a tracker object for the Ematic API Key you have specified.
Adding email address into the script
Once the user logs in, you need to pass the email with this method in order to track accurately:
ematics("set", "email", "<email of the user logged in if applicable>")
Initializing Ematic.js on RequireJS:
If your website is using requireJS, use the following configuration in order to initialize the object properly:
require.config({
config: {
'ematics': {
'apikey' : "<environment specific ematic apikey",
'opt' : {
country_iso: "<country>",
currency_iso: "<currency>",
language_iso: "<language>"
}
}
},
paths: {
"ematics": "//api.ematicsolutions.com/v1/ematic.min"
}
});
require(["ematics"], function() {
ematics("set", "email", "<email of the user logged in if applicable>");
//execute your code
});
Important Note: Cookies are used to track unique visitors and to limit the display of the popups. Cookies must be cleared in order to re-test the display of the popups.
onAfterSubscribe Event
Alternately, you can trigger your custom code when a visitor subscribes using Bye-iQ by defining an event as shown below as part of the “opt” object that is passed on when you initialize the library.
<script>
...
//define the event before initializing
opt.events = {
onAfterSubscribe: function(email) {
//execute your code
}
};
//then initialize
ematics("create", ematicApikey, opt);
</script>