Skip to content

Instantly share code, notes, and snippets.

window.usabilla_live("setEventCallback", function(category, action, label, value){
function sendEvent(usblCategory, action, label, value){
var trackers = ga.getAll();
for(var i = 0; i < trackers.length; i++){
var trackerName = trackers[i].get('name');
ga(trackerName + '.send', 'event', usblCategory, action, label, value);
}
}
if(category === "feedback"){
sendEvent("Usabilla Feedback", action, label, value);
@UsabillaSuccess
UsabillaSuccess / usbl-virtpageview-react.js
Last active July 19, 2017 12:31
usbl-virtpageview-react
Router.run(routes, Router.HistoryLocation, function (Handler) {
React.render(<Handler/>, document.body);
// your code here
window.usabilla_live('virtualPageView');
});
@UsabillaSuccess
UsabillaSuccess / usbl-virtpageview-vuejs.js
Last active July 19, 2017 12:30
usbl-virtpageview-vuejs
import router from './router';
router.afterEach((to, from) => {
// do your stuff
window.usabilla_live('virtualPageView');
});
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
import { Router, NavigationStart, Event as NavigationEvent } from '@angular/router';
constructor(router:Router) {
router.events.forEach((event: NavigationEvent) => {
if(event instanceof NavigationEnd) {
// do your stuff
window.usabilla_live('virtualPageView');
}
});
}
@UsabillaSuccess
UsabillaSuccess / usbl-virtpageview-vanillajs.js
Last active July 19, 2017 12:28
usbl-spa-code-vanillajs
window.history.pushState('page2', 'Page 2 Title', '/page2.html');
window.usabilla_live('virtualPageView');
<script type="text/javascript">
var buttons = {'button1': "4937d621b6d2", 'button2': "e1bcdbe76eda"};
var usabillaUrl = "//w.usabilla.com/" + buttons.button1 + ".js";
/*{literal}<![CDATA[*/window.lightningjs||function(c){function g(b,d){d&&(d+=(/\?/.test(d)?"&":"?")+"lv=1");c[b]||function(){var i=window,h=document,j=b,g=h.location.protocol,l="load",k=0;(function(){function b(){a.P(l);a.w=1;c[j]("_load")}c[j]=function(){function m(){m.id=e;return c[j].apply(m,arguments)}var b,e=++k;b=this&&this!=i?this.id||0:0;(a.s=a.s||[]).push([e,b,arguments]);m.then=function(b,c,h){var d=a.fh[e]=a.fh[e]||[],j=a.eh[e]=a.eh[e]||[],f=a.ph[e]=a.ph[e]||[];b&&d.push(b);c&&j.push(c);h&&f.push(h);return m};return m};var a=c[j]._={};a.fh={};a.eh={};a.ph={};a.l=d?d.replace(/^\/\//,(g=="https:"?g:"http:")+"//"):d;a.p={0:+new Date};a.P=function(b){a.p[b]=new Date-a.p[0]};a.w&&b();i.addEventListener?i.addEventListener(l,b,!1):i.attachEvent("on"+l,b);var q=function(){function b(){return["<head></head><",c,' onload="var d=',n,";d.g