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
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
270
[JAWS-UG横浜 #76] イケてるアップデートを宇宙いち早く紹介するよ!
maroon1st
0
460
MCP with Cloudflare Workers
yusukebe
2
220
php-conference-japan-2024
tasuku43
0
290
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
770
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
340
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
103 Early Hints
sugi_0000
1
230
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
760
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
快速入門可觀測性
blueswen
0
360
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
Featured
See All Featured
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Practical Orchestrator
shlominoach
186
10k
4 Signs Your Business is Dying
shpigford
181
21k
Scaling GitHub
holman
458
140k
Producing Creativity
orderedlist
PRO
341
39k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Music & Morning Musume
bryan
46
6.2k
The Cult of Friendly URLs
andyhume
78
6.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Java REST API Framework Comparison - PWX 2021
mraible
28
8.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”