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
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
230
Ethereum_.pdf
nekomatu
0
460
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
120
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
初めてDefinitelyTypedにPRを出した話
syumai
0
420
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
630
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
C++でシェーダを書く
fadis
6
4.1k
Jakarta EE meets AI
ivargrimstad
0
200
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
「今のプロジェクトいろいろ大変なんですよ、app/services とかもあって……」/After Kaigi on Rails 2024 LT Night
junk0612
5
2.2k
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Featured
See All Featured
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Typedesign – Prime Four
hannesfritz
40
2.4k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Rails Girls Zürich Keynote
gr2m
94
13k
How to Think Like a Performance Engineer
csswizardry
20
1.1k
Designing the Hi-DPI Web
ddemaree
280
34k
BBQ
matthewcrist
85
9.3k
Become a Pro
speakerdeck
PRO
25
5k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
For a Future-Friendly Web
brad_frost
175
9.4k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
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”