Skip to content

Commit

Permalink
tracking de eventos de botones con google analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Mantish committed Apr 22, 2015
1 parent 252ac07 commit db81d9e
Showing 1 changed file with 42 additions and 7 deletions.
49 changes: 42 additions & 7 deletions wp-content/themes/otto/js/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ OM.Views.MainView = Backbone.View.extend({
'click .menu-toggle': 'toggleMenu',
'click .main-nav .menu-item a': 'hideMenu',
'click main a': 'hideMenu',
'click .main-nav .menu-item:nth-child(6) a': 'showFooter',
'click .footer-toggle': 'showFooter',
'click .main-nav .menu-item:nth-child(6) a': 'contactClick',
'click .footer-toggle': 'footerToggle',
'click .footer-close': 'hideFooter',
'click .current-lang': 'toggleLangs',
//'change #contact-medium': 'changeInputType',
Expand Down Expand Up @@ -62,7 +62,9 @@ OM.Views.MainView = Backbone.View.extend({
e.preventDefault();
if ($(window).scrollTop() > 0) {
$.scrollTo( 0, 500 );
ga('send', 'event', 'button', 'click', 'menu', 'open');
} else {
ga('send', 'event', 'button', 'click', 'menu', 'close');
this.hideMenu(true);
}
},
Expand All @@ -75,15 +77,26 @@ OM.Views.MainView = Backbone.View.extend({
$.scrollTo( menuHeight, 0 );
}
},
showFooter: function(e) {
contactClick: function(e) {
e.preventDefault();
ga('send', 'event', 'button', 'click', 'contacto');
this.showFooter();
},
footerToggle: function(e) {
e.preventDefault();
if ((window.innerHeight + $(window).scrollTop()) < document.documentElement.scrollHeight) {
$.scrollTo( 'max', 500 );
ga('send', 'event', 'button', 'click', 'yo quiero', 'open');
this.showFooter();
} else {
//scrolled to the bottom
ga('send', 'event', 'button', 'click', 'yo quiero', 'close');
this.hideFooter();
}
},
showFooter: function() {
$.scrollTo( 'max', 500 );
return false;
},
hideFooter: function() {
var scrollOffset = document.documentElement.scrollHeight - window.innerHeight - $('.contact-footer').outerHeight();
$.scrollTo( scrollOffset, 500 );
Expand Down Expand Up @@ -163,7 +176,12 @@ OM.Views.LabsView = Backbone.View.extend({
clickToggle: function(e) {
var $project = $(e.currentTarget).parent();
$(e.currentTarget).toggleClass('more less');
$project.find('.more-info').slideToggle();
var $moreInfo = $project.find('.more-info');
if ($moreInfo.is(':hidden')) {
var title = $project.find('.project-title').text();
ga('send', 'event', 'button', 'click', 'lab-more', title);
}
$moreInfo.slideToggle();
$.scrollTo( $project, 500, {offset: {top:-50}} );
}
});
Expand Down Expand Up @@ -231,7 +249,14 @@ OM.Views.ProjectsView = Backbone.View.extend({
var $project = $(e.currentTarget).parent();
$project.toggleClass('on off');
$project.find('.toggle-details').toggleClass('more less');
$project.find('.more-info').slideToggle(function(){

var $moreInfo = $project.find('.more-info');
if ($moreInfo.is(':hidden')) {
var title = $project.find('.project-title').text();
ga('send', 'event', 'button', 'click', 'work-more', title);
}

$moreInfo.slideToggle(function(){
if($(this).is(':visible')){
var $carousel = $project.find('.owl-carousel');
$carousel.owlCarousel({
Expand Down Expand Up @@ -299,7 +324,14 @@ OM.Views.PersonsView = Backbone.View.extend({
var $person = $(e.currentTarget).parent();
$person.toggleClass('abierto cerrado');
$(e.currentTarget).toggleClass('more less');
$person.find('.person-info').slideToggle();

var $personInfo = $person.find('.person-info');
if ($personInfo.is(':hidden')) {
var title = $person.find('.person-name').text();
ga('send', 'event', 'button', 'click', 'team-more', title);
}

$personInfo.slideToggle();
$.scrollTo( $person, 500, {offset: {top:-100}} );
}
});
Expand Down Expand Up @@ -331,16 +363,19 @@ OM.Views.TeamView = Backbone.View.extend({
newCollection = new OM.Collections.TeamCollection();
$('.active-team').removeClass('active-team color-bg').css('background-color', '');
$('.team-core').addClass('active-team color-bg');
ga('send', 'event', 'button', 'click', 'team-tab', 'nucleo');
}
else if($(e.currentTarget).hasClass('team-nodes')){
newCollection = new OM.Collections.NodesCollection();
$('.active-team').removeClass('active-team color-bg').css('background-color', '');
$('.team-nodes').addClass('active-team color-bg');
ga('send', 'event', 'button', 'click', 'team-tab', 'nodos');
}
else if($(e.currentTarget).hasClass('team-friends')){
newCollection = new OM.Collections.FriendsCollection();
$('.active-team').removeClass('active-team color-bg').css('background-color', '');
$('.team-friends').addClass('active-team color-bg');
ga('send', 'event', 'button', 'click', 'team-tab', 'amigos');
}
}
this.renderTeam(newCollection)
Expand Down

0 comments on commit db81d9e

Please sign in to comment.