■onclick属性のイベント計測source例
・gtag(event_nameがデフォルトのaction)
gtag('event', 'event_name', {
'event_category': string,
'event_label': string,
'value' : integer
});
{'nonInteraction':true} = 直帰率に影響しない
{'nonInteraction':false} = 直帰率に影響する
onclick="ga('send', 'event', 'カテゴリ', 'アクション', 'ラベル', 値, {'nonInteraction': true});"
$("#AmazonPayButton img").click(function(){
ga('send', 'event', 'outbound', 'click', 'AmazonPayButton', 1, {'nonInteraction':true});
console.log("on click");
}
・_gaq.push
onclick="_gaq.push(['_trackEvent', 'カテゴリ', 'アクション', 'ラベル', 値, opt_noninteraction]);"
・pageTracker
onclick="pageTracker._trackEvent('カテゴリ', 'アクション', 'ラベル', int);"
■クロスドメイン計測source例
・gtag
gtag('config', 'GA_TRACKING_ID_1', {
'linker': {
'domains': ['example-1.com', 'example-2.com']
}
});
・ga
ga('create', 'UA-xxxxxxx-x', 'auto', {'allowLinker': true});
ga('require', 'linker');
ga('linker:autoLink', ['domain1', 'domain2'], false, true);
・_gaq.push
_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);
click
・pageTracker
pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);
click
■仮想ページビュー
・gtag
gtag('config', 'GA_MEASUREMENT_ID', {
'page_title' : 'homepage',
'page_location' : 'https://',
'page_path': '/home'
});
・ga
ga('send', 'pageview', {
'page':'/example.html',
'title':'PDFファイル'
});