Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
User Action Tracking - Google Analytics
Search
tureki
March 02, 2014
Programming
0
140
User Action Tracking - Google Analytics
取巧的使用Google Analytics來儲存過億筆的使用者和遊客的行為資料,省去伺服器建置和維護成本,適合小企業使用。
tureki
March 02, 2014
Tweet
Share
More Decks by tureki
See All by tureki
Google Cloud Platform 入門
tureki
0
170
Sublime Text 入門
tureki
2
280
Other Decks in Programming
See All in Programming
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
120
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
flutterkaigi_2024.pdf
kyoheig3
0
140
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
340
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2.2k
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
受け取る人から提供する人になるということ
little_rubyist
0
240
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
300
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
43
13k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.4k
How GitHub (no longer) Works
holman
310
140k
The Pragmatic Product Professional
lauravandoore
31
6.3k
The Language of Interfaces
destraynor
154
24k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
What's in a price? How to price your products and services
michaelherold
243
12k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
1.3.2014 User Action Tracking Google Analytics by tureki
“㘸౸ཁtracking༻ऀߦҝత࣌ީ”
“։ᚙऀ/ఔࢣ။ইᡵے”
“Ҽҝ౸తୈҰ݅ࣄबੋཁዎኄṶଘʁ”
“ಓधཁݐஔҰݸେత䭘䭓Գ(ࢿྉݿ)ʁ” “ෆఀత။һ҃༡٬㑌ݸಈ࡞ه㑚౸䭘䭓Գ㚎ʁ”
“ڥݐஔɼҡޢຊߴ㠷...”
“զੋҰݸখɼಓबᔒ༗ল࣌ল᭝తํࣜ䆩ʁ” –ѩ嚎ʂ
“༗త...ԼိबཁհతबੋṜछল࣌ল᭝ํ๏”
Google AnalysicʢGAʣ
“GAʁෆबੋ์ࡏfooterबྃ䆩ʁ”
“ಹੋҰൠ༻๏ɼଖመ㟬ؐՄҎߋᡏ໌తར༻ሏ”
Google Analysicʢ༏ᴍʣ ✤ ໔අɼਃாᥒཱଈ༻! ✤ ෆधݐஔ։ᚙثʢࢿྉݿʣ! ✤ ෆध፦৺༰ྔʢແఈಎʣ! ✤ ෆधҡޢɼڰ㟚ࢿྉबሣྃ!
“໔අ័ੋཁग़Ұࠣၢ”
Google Analysicʢ᠍ᴍʣ ✤ ࢿྉऔग़ֱຑʢध༻APIʣ! ✤ ࢿྉ༗৽⃧ɼᔒ༗मվɼ႟আ! ✤ ࢿྉ༗࣌ީ။࿙ᎃ! ✤ Ұఱࢿྉएաଟɼध1ɼ2ఱ࠽။ग़ݱ!
✤ 㟬ඞਢྃղGoogle Analysic API
“௨ৗզ။ሡTrackingၷྨ”
User Interface Track ʢUI Trackʣ ✤ հ໘తtracking! ✤ ྫ:ทݸท໘తݸეҬతݸ҈ᭃతᴍ㐝㐫گ! ✤
መࡍگ:A᧷ಘṜݸ҈ᭃ์ߚ৭ֱɼB᧷ಘ์→৭ ɼಹ౸ఈ䬟Ұݸʁ! ✤ զ၇ՊላᴍɼTrack UIʂᏐᎦ။㘸ʂ
Backend Track ✤ ༻㖽എޙੳతtracking! ✤ ྫ:Userྃॄኄɼങྃॄኄݸ! ✤ ҝྃ၏Data Miningɼ༻㖽ڵझ! ✤
መࡍگ:။һ࠷تᓣ䬟Ұݸྨʁ࠷تᓣ䬟Ұݸ! ✤ ޙ༻:(php,python etc.)ሡࢿྉpushڅGA
“ࡏመ၏લ,䓟ؐඞਢྃղ...”
Track Page ViewʢGAʣ
Ꭿྫ ✤ ଖመGAత᪨ᛰ์౸ทԼํɼबੋࡏࣥߦTrack Page ViewṜݸಈ࡞ GA။ሡ֘ท໘తurltitleڅه㑚ىိɻ
Ռᅿੋ/user/register/index.html! ! ಹኄGAब။ሡሏᏓ:! user/! ᵓᴷᴷ register/! ᴹ ᵓᴷᴷ index.html! !
बੋ㘸 / ᥒGA။ࣗಈሡ㚎༰။Ꮣ㑚ڃʢ/ෆೳစ༻ʣɻ
“ॏᴍိྃ” “ՌTrack Page View తࢿྉೳࣗݾDIYෆबྃʁ”
“ᔒࡨԼိबੋཁ༻GA-APIိၚૹ㟬ཁతࢿྉ” https://developers.google.com/analytics/devguides/collection/ analyticsjs/ (ps:༝ԙGAቮ༗৽൛Tracking Code,ԟޙతൣྫ။৽൛ҝओ)
։GA ҝྃෆഁᆦݪိతGAɼ௨ৗզత၏๏။ሡGA։
Ꭿྫ ✤ UA-XXXXX-01 -> ҰൠGA! ✤ UA-XXXXX-02 -> UI Track
GA(lab)! ✤ UA-XXXXX-03 -> UI Track GA(ਖ਼ࣜ)! ✤ UA-XXXXX-04 -> Backend Track GA(lab)! ✤ UA-XXXXX-05 -> Backend Track GA(ਖ਼ࣜ)
զݸਓੋ᧷ಘṜᒬ࠽ཧɼ! ! ଌࢼ࣌ީब༻labతTracking Numberɼ! ! ਖ਼ࣜڥबه㑚ࡏਖ਼ࣜTracking Numberɼ! ! ṜੋҝྃࢭGAత㑚ࢿྉ݁ߏඃഁᆦɼ! !
㟬ཁهಘGAೳ৽⃧ɼᔒ༗मվ႟আ
Ұݸท໘ੋ༰ڐݐཱၷݸመྫɼҎԼੋgaڅతൣྫɿ! <script>! (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){! (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),! m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)! })(window,document,'script','//www.google-analytics.com/analytics.js','ga');! ! ga('create', 'UA-XXXXX-1',
'your.domain');! ! </script>! ! Ұݸท໘ੋಉ࣌ՄҎݐཱଟݸመྫతɼɿ! var ga_1 = ga('create', 'UA-XXXXX-1', 'your.domain');! var ga_2 = ga('create', 'UA-XXXXX-2', 'your.domain');
։࢝መ၏ UI Track
ൣྫҰ ڥɿटท༗ݸᅷยეҬɼ౸ఈେᅷᴍ㐝ߴɼؐੋখᅷଟʁ େᅷ খᅷ খᅷ খᅷ େᅷɿ! /index/img-panel/large/[img]! খᅷ:! /index/img-panel/small/[img]
ᙛIMGඃඃᴍ㐝࣌ީʢJSʣ var ga_ui_track = ga.create('UA-XXXXX-02', 'auto', {'name': 'UA-XXXXX-02'});! ga_ui_track.send('pageview',{page:"/index/img-panel/left/img"});! !
㟬ࡏGAతޙबೳଈ࣌౸ɼᅷɿ मվޭʂ! ! ᡏ໌త㟬။ᚙݱ! ! ଖመઃܭPATH(/index/img-panel/left/img)࠽ੋॏᴍ,! ! ෆಉతधٻ။༗ෆಉత㑚݁ߏ
ҝྃཁᩋ᪨Ꮣಘ؆ᄸɼզత၏๏ੋሡ᪨తtrack์ࡏhtml㚎! <img src="small.jpg" track="/index/img-panel/small/img"/>! ! ༻jQueryఁଌશҬతattr:! var ga_ui_track = ga.create('UA-XXXXX-02',
'auto', {'name': 'UA-XXXXX-02'});! ! jQuery('body').on('click', '[track]', function(e) {! ! ! var _str_track = jQuery(this).attr("track");! ! ! ga_ui_track.send('pageview',{page:_str_track});! ! });
㟬Մ౸ҎԼᅿऔಘൣྫҰతTesting Code! ! https://gist.github.com/tureki/9303954! ! Ҽҝ೭ޙతመ၏ᬓाҰᒬɼबෆ࠶࡞ྃ
༻GAޙ एཁፙେᅷɼबߦҝ->㚎༰->፺ਘԼlarge/imgɼᅷɿ ҙɼޙGAޙ༰ෆ༰қፙ౸㟬ཁతࢿ㘤ɼऔܾ㟬తPATHዎኄઃܭʂ
ൣྫೋ ڥɿՌհ໘ੋશҬheaderɼ֘ዎኄઃܭʁ header login ၊ઃੋొೖ҈ᭃ! ! ՄҎߟྀ:/common/header/menu/[btn:login]
զ။ሡท໘ৗग़ݱతUI์ࡏcommon㚎! ! ୠੋṜᒬઃܭᦒવೳሡऔಘheaderతᏐᎦ! ! ୠᔒ㭎๏औಘटทheaderඃᴍ㐝త㐫گ! ! ॴҎզ။टทheaderඃᴍ㐝త࣌ީɼಈଶሡࢿྉኺ! /common/header/menu/[btn:login]! Ꮣ! /index/common/header/menu/[btn:login]!
! ࡏޙՌཁऔશ෦ࢿྉबԼ /common/header/! ! ཁᄸᘐऔटทबԼ /index/common/header/! ! ࢸԙཁዎኄᏗṜੋಹҰทઃܭPATHबੋ㟬తޭ՝ྃɻ
“هಘʂPATHॏཁ!”
ԿଌࢼDebugʁ ✤ ༻㟬తLAB Tracking Number! ✤ ༻GAํᎎ݅! ✤ https://chrome.google.com/webstore/detail/google- analytics-debugger/
jnkmfdileelhofjcijamephohjechhna! ✤ ༻GAޙతଈ࣌༬᧸
։࢝መ၏Backend Track
جຊ্Backend TrackUI TrackੋҰᒬత,! ! ᮫伴ࡏԙPATHతઃܭ! ! ؐ༗ه㑚ํࣜࡏޙ! ! ຊൣྫ࠾༻PHP:! !
https://github.com/thomasbachem/php-ga
ൣྫҰ ڥ:။һࡏटทɼՄҎሡPATHઃܭ! /member/{Member ID}/{Action}/{Object}! बੋ! /member/1/view/page/index! ! ༡٬ࡏटท! /guest/view/page/index
ൣྫೋ ။һޭḼ+ိኺಹҰทᴍաိʁ! /member/1/register/ʢိݯʣ! ! 㟬ՄҎઃܭ! $str = "/member/1/register/(from:".$_SERVER['HTTP_REFERER'].")";! ! बੋ㘸ɼ㟬Ѫዎኄ߹ੋ༝㟬ࡏܾఆ
ൣྫࡾ ။һങྃҰݸɼ၊ઃ༗ྨɼ༗IDɻ! /member/{Member ID}/buy/item/{CATALOG ID}/{ITEM ID}! बੋ! /member/1/buy/item/2/3! ! PHPޙ༻తൣྫɿ!
https://github.com/thomasbachem/php-ga! ! ॏᴍबࡏɿ! $tracker->trackPageview("/member/1/view/page/index", $session, $visitor);
GAޙ፺ਘ एཁፙྨ2ɼ፺ਘबԼ! /item/2/! ! ՌཁፙITEM ID 3ɼ፺ਘबԼ! /item/2/3/! ! ҙɿGAతsearchࢧԉregexɼॴҎՌ㟬။ਖ਼نɼ౦ߋፙ!
regex URL! ! https://support.google.com/analytics/answer/1034324?hl=en
Guestత
“༡٬ՄҎ၏౸૾။һಹᒬతه㑚䆩ʁ”
“ՄҎత,ੋੋ㟬ዎኄ၏ʁGAੋݸ䭘䭓Գɼ༻ሏత ਓੋ㟬ɻ”
“Ṝཫڅݸ؆ᄸతࢥ࿏ɿ”
ᩋguest༗ݸӬٱతCookieɼPATHઃܭ! /guest/{COOKIE}/view/page/index! ! ᙛguestᏓ။һ҃ొೖ࣌ɼሡguestతcookiemember ID mappingىိ! ! 㟬ब။ಓṜݸ။һࡏؐᔒొೖḼલ၏ྃॄኄࣄɻ! ! ॏᴍࡏMappingతࢿྉ㟬ཁṶଘىိɼҼҝGAతࢿྉ৽⃧ޙੋແᚙमվతɼ!
! बੋ㟬ແ๏ሡ೭લه㑚త! /guest/{COOKIE}/view/page/index! Ꮣ! /member/{member ID}/view/page/index! ! mapping cookieతࢿྉࢸԙཁṶଘࡏಹʁ! ! զݸਓલੋ༻ElasticsearchṶଘɻ
GAతج४ ৽൛༗ఏڙࣗగ! ! Custom Dimensions and Metricsɼ! ! बੋ㟬ೳࣗగᴍ㐝ྔ! !
֤ҐՄҎࣗߦࡧ
࠷ޙ
“Ṝछํ๏ቮመ༻ۙ2ɼҎԼBackend TrackతṶଘྔ” ቮ໔අṶଘաԯ...
զݸਓ᧷ಘҎ্၏๏ٱ೭ܭద߹খܕެ࢘! ! ༗ࢿݯؐੋݐٞ༻ਖ਼ৗతํࣜڈ၏େᏐᎦੳ! ! ඟᰈݱࡏٕज़ख़! ! AWS༗ఏڙྨࣅత
“ᔒ༗࠷తํ๏ɼ༗࠷ద߹㟬తํ๏”! “ࠜᎦ㟬తڥɼબᎩ࠷ద߹ݱࡏత၏๏࠽ੋԦಓ”
“END”