Site events integration using Javascript

There are a few steps to complete integration:

  • The main javascript code, which needs to be present on all pages
  • Events integration codes, which are present on some specific pages.
  • Before creating site events, it’s recommended to create the product feed. Some elements are required to be indentical in both (product_id, category_id).

Helpful links:

  • How to create a product feed: Go here
  • How to import exising users: Go here
  • How to send ecommerce events: Go here

For importing old purchase history, please get in touch with us.

 

1. Add Main Loader Javascript

  • System’s general js file to make it work.
  • * This step is mandatory
  • Needs to be included before on every page before the closing </head> tag.
  • To have loader file on a different domain then the one account was created for just change d value on line 3.
<script>
(function(){
var d = window.location.hostname.replace ("www.","");  //replace this with your own domain, if you need the script to run anywhere 
var fl = function (u) {
var l = document.createElement('script'); l.type = 'text/javascript'; l.async = true; l.src = u;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(l, s);
};
fl ("https://files2.vtcdn.net/" + d + "/loader.min.js");
window._vteq = window._vteq || [];
setTimeout(function(){if (!window._vtsdk) {fl ('https://storage.googleapis.com/cdn.vtcdn.net/' + d + '/loader.js');}}, 1100);
})();
</script>

 

For example if you want the same loader (so all events and data sits under 1 account) to run on domain.com (account main domain) and also blog.domain.com you need to modify like below:

<script>
(function(){
var d = 'domain.com';
var fl = function (u) {
var l = document.createElement('script'); l.type = 'text/javascript'; l.async = true; l.src = u;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(l, s);
};
fl ("https://files2.vtcdn.net/" + d + "/loader.min.js");
window._vteq = window._vteq || [];
setTimeout(function(){if (!window._vtsdk) {fl ('https://storage.googleapis.com/cdn.vtcdn.net/' + d + '/loader.js');}}, 1100);
})();
</script>

 

Using only the main javascript loader you will be able to do the following:

  • onsite campaigns, interactions and email collectors
  • push notifications
  • simple email newsletters

What you’re missing if you don’t proceed and install ecommerce events:

  • product recommendations (both onsite and in emails)
  • cart and checkout recovery campaigns
  • email retargeting
  • site remarketing (bring visitors back based on their interests)
  • ecommerce analytics

Related Articles