function trackEvent(category,action,label,value) { dataLayer.push({ 'event':'tracking', 'eventCategory':category, 'eventAction':action, 'eventLabel':label, 'eventValue':value }); } function trackEvent_nonInteraction(category,action,label,value) { dataLayer.push({ 'event':'tracking_noninteraction', 'eventCategory':category, 'eventAction':action, 'eventLabel':label, 'eventValue':value }); } //Twitter click SocialInteraction(call back) function clickEventToAnalytics (intentEvent) { if (!intentEvent) return; // console.log('click finish'); var socialNetwork = 'twitter'; var socialAction = intentEvent.region; var socialTarget = $(intentEvent.target).attr('data-url') ? $(intentEvent.target).attr('data-url') : window.location.href; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); } //Twitter click SocialInteraction(click event) $(function(){ $('#twitterEvent').click(function() { // console.log('twitter click'); var socialNetwork = 'twitter'; var socialAction = 'click'; var socialTarget = window.location.href; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); }); }); //Twitter tweet SocialInteraction function tweetIntentToAnalytics (intentEvent) { if (!intentEvent) return; // console.log('tweet finish'); var socialNetwork = 'twitter'; var socialAction = 'tweet'; var socialTarget = $(intentEvent.target).attr('data-url') ? $(intentEvent.target).attr('data-url') : window.location.href; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); } //google+ SocialInteraction function plusoneToAnalytics () { // console.log('tweet finish'); var socialNetwork = 'google'; var socialAction = 'plusone'; var socialTarget = window.location.href; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); } //Line SocialInteraction $(function(){ $('#sendline').click(function() { // console.log('line click'); var socialNetwork = 'line'; var socialAction = 'send'; var socialTarget = window.location.href; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); }); }); // Facebook SocialInteraction(callback) $(function(){ FB.Event.subscribe('edge.create', function(targetUrl) { var socialNetwork = 'facebook'; var socialAction = 'like'; var socialTarget = targetUrl; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); }); FB.Event.subscribe('edge.remove', function(targetUrl) { var socialNetwork = 'facebook'; var socialAction = 'unlike'; var socialTarget = targetUrl; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); }); }); //Facebook SocialInteraction(click event) $(function(){ $('#facebookEvent').click(function() { // console.log('facebook click'); var socialNetwork = 'facebook'; var socialAction = 'share'; var socialTarget = window.location.href; snsLog(socialNetwork,socialAction,socialTarget); dataLayer.push({ 'event': 'socialEvent', 'socialNetwork': socialNetwork, 'socialAction': socialAction, 'socialTarget': socialTarget }); }); }); // SNS Event Log Regist function snsLog(network, action, target) { var data = { socialNetwork: network, socialAction: action, socialTarget: target }; $.ajax({ url: '/do/sns/log', type: 'post', data: data, success: function(html) { } }); }