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
CSC305 Lecture 26
javiergs
PRO
0
140
Security_for_introducing_eBPF
kentatada
0
110
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
470
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
220
Zoneless Testing
rainerhahnekamp
0
120
MCP with Cloudflare Workers
yusukebe
2
220
これでLambdaが不要に?!Step FunctionsのJSONata対応について
iwatatomoya
2
3.6k
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
130
range over funcの使い道と非同期N+1リゾルバーの夢 / about a range over func
mackee
0
110
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
5
1.2k
Featured
See All Featured
Writing Fast Ruby
sferik
628
61k
Being A Developer After 40
akosma
87
590k
Docker and Python
trallard
42
3.1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Testing 201, or: Great Expectations
jmmastey
40
7.1k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Raft: Consensus for Rubyists
vanstee
137
6.7k
Practical Orchestrator
shlominoach
186
10k
Building Applications with DynamoDB
mza
91
6.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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”