Purpose of silk.js is to collect some information from client side about visitor's source and some custom actions on a web page. It sends info to the back-end about where was visitor from and what did he do on the site. This library was written for a service UpFinder http://upsidefinder.com/
webpack
- to start development mode
DEBUG=t webpack
- to start debug mode (use DEBUG constant in code)
NODE_ENV=production webpack
to build for production
npm run deploy <production|staging> [debug]>
- don't afraid about "ERR Protocol error: unbalanced quotes in request", it will save silk lib on the server anyway
npm start
- run server, open localhost:8000 in browser and run webpack for hot changes in silk
- Put this code into html of clientside:
- staging
<script>!function(){var t=new XMLHttpRequest;t.open("GET","http://staging.up-finder.com/script",!0),t.onreadystatechange=function(){if(4==t.readyState){var e=t.responseText,n=document.createElement("script");n.type="text/javascript",n.text=e,document.body.appendChild(n)}},t.send()}();</script>
- production
<script>!function(){var t=new XMLHttpRequest;t.open("GET","http://production.up-finder.com/script",!0),t.onreadystatechange=function(){if(4==t.readyState){var e=t.responseText,n=document.createElement("script");n.type="text/javascript",n.text=e,document.body.appendChild(n)}},t.send()}();</script>
- Available hooks on interaction with elements at the client page:
data-silk-submit="custom_event_name"
- add this attribute to tag with supported submit event (usually ). warning: we can serialize tags with filled attribute "name" only. empty "name" value will not pass.
right
<input type="text" name="field" value="hello">
wrong
<input type="text" value="hello">
data-silk-click="custom_event_name"
- add this attribute to tag with supported click event (usually any clickable elements like , , ...)
Value of "custom_event_name" is passing with another data to server, so it helps to make detailed goals
- CPC, CPM, CPA - parse url (if exists "utm_...", "xclid", etc)
- Direct - referal_uri is empty
- Inner - referal_uri is not empty and match client domain itself
- Referal - referal_uri does not match any regular in list of search engines and so on (e.g. "yandex.ru", "mail.ru", "rambler.ru", "google.com", etc)
- Organic - referal_uri matches some regular in list of search engines and so on