{"id":32523,"date":"2015-12-13T14:29:55","date_gmt":"2015-12-13T22:29:55","guid":{"rendered":"https:\/\/blog.btrax.com\/jp\/?p=32523"},"modified":"2020-08-10T09:36:34","modified_gmt":"2020-08-10T00:36:34","slug":"ga-slack","status":"publish","type":"post","link":"https:\/\/blog.btrax.com\/jp\/ga-slack\/","title":{"rendered":"KPI\u3092\u30c1\u30fc\u30e0\u306b\u6d78\u900f\u3055\u305b\u308b\uff01Google Analytics\u304b\u3089\u30c7\u30fc\u30bf\u3092Slack\u306b\u81ea\u52d5\u6295\u7a3f\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<div class='wp_content_tag clearfix'><p>Web\u30b5\u30a4\u30c8\u3084\u30a2\u30d7\u30ea\u306f\u3001\u554f\u8005\u6570\u306f\u3082\u3061\u308d\u3093\u30da\u30fc\u30b8\u5358\u4f4d\u306e\u95b2\u89a7\u6642\u9593\u306e\u5e73\u5747\u306a\u3069\u3055\u3089\u306b\u306f\u4f55\u4eba\u306e\u4eba\u304c\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u304b\u306a\u3069\u30e6\u30fc\u30b6\u30fc\u306e\u591a\u304f\u306e\u884c\u52d5\u3092\u8a18\u9332\u3067\u304d\u308b\u3002<\/p>\n<p>\u4ee3\u8868\u7684\u306a\u30c4\u30fc\u30eb\u306fGoogle\u304c\u63d0\u4f9b\u3059\u308bGoogle Analytics\u3067\u3001\u3068\u3093\u3069\u306e\u30b5\u30a4\u30c8\u306b\u5c0e\u5165\u3055\u308c\u3066\u3044\u308b\u3068\u8a00\u3063\u3066\u3082\u904e\u8a00\u3067\u306f\u306a\u3044\u3002\u30c7\u30fc\u30bf\u3092\u7528\u3044\u3066\u6539\u5584\u3092\u7e70\u308a\u8fd4\u3059\u3053\u3068\u306f\u5e83\u304f\u884c\u308f\u308c\u3066\u304a\u308a\u3001\u7279\u306b\u91cd\u8981\u306a\u6307\u6a19\u3092KPI\u3068\u3057\u3066\u8a2d\u5b9a\u3059\u308b\u5834\u5408\u304c\u591a\u3044\u3002<\/p>\n<p>\u3057\u304b\u3057\u3001\u8a2d\u5b9a\u3057\u305f\u307e\u3067\u306f\u3044\u3044\u304c\u3001\u305d\u306e\u5f8c\u3042\u307e\u308a\u6d3b\u7528\u3055\u308c\u306a\u3044KPI\u3082\u591a\u3044\u306e\u3082\u5b9f\u60c5\u3060\u3002\u6bce\u65e5\u3001KPI\u3092\u30c4\u30fc\u30eb\u3067\u78ba\u8a8d\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u96c6\u8a08\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30e1\u30f3\u30d0\u30fc\u306b\u30b7\u30a7\u30a2\u3059\u308b\u3053\u3068\u306f\u624b\u9593\u304c\u304b\u304b\u308a\u3001\u591a\u5fd9\u306a\u696d\u52d9\u306e\u4e2d\u3067\u3064\u3044\u304a\u3056\u306a\u308a\u306b\u306a\u308b\u3053\u3068\u3082\u591a\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u3072\u3069\u3044\u5834\u5408\u306b\u306f\u3001\u8a2d\u5b9a\u3055\u308c\u305fKPI\u81ea\u4f53\u304c\u5fd8\u308c\u53bb\u3089\u308c\u308b\u3053\u3068\u3082\u3042\u308b\u3002\u305d\u3053\u3067\u4eca\u56de\u306f\u3001\u81ea\u52d5\u7684\u306bGoogle Analytics\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3001KPI\u306e\u9054\u6210\u7387\u3092\u8a08\u7b97\u3057\u3066\u3001Slack\u306b\u6295\u7a3f\u3057\u3066\u307f\u3088\u3046\u3002\u3053\u308c\u3067\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30e1\u30f3\u30d0\u30fc\u5168\u54e1\u304cKPI\u3092\u7c21\u5358\u306b\u610f\u8b58\u3057\u3066\u3001\u3088\u308a\u81ea\u5f8b\u7684\u306b\u884c\u52d5\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u4f7f\u7528\u8a00\u8a9e Node.js<\/h3>\n<p>\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u3068\u3057\u3066Node.js\u3092\u4f7f\u3046\u3053\u3068\u306b\u3059\u308b\u3002\u4eca\u56de\u306f\u3001<a href=\"https:\/\/coffeescript.org\/\" target=\"_blank\" rel=\"noopener\">CoffeeScript<\/a>\u3092\u4f7f\u3063\u305f\u3002CoffeeScript\u3068\u306f\u3001JavaScript\u306e\u30b3\u30fc\u30c9\u3092\u751f\u6210\u3059\u308bRuby\u306b\u4f3c\u305f\u30b9\u30af\u30ea\u30d7\u30c8\u8a00\u8a9e\u3067\u3001\u5b89\u5168\u6027\u3068\u53ef\u8aad\u6027\u306e\u9ad8\u3044\u30b3\u30fc\u30c9\u3092\u3001\u8a18\u8ff0\u91cf\u3092\u6e1b\u3089\u3057\u3066\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306f\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u53ef\u80fd\u3002<\/p>\n<p>[code]<br \/>\n$ npm install -g coffee-script<br \/>\n[\/code]<\/p>\n<h3>Google Analytics\u306e\u5024\u3092\u53d6\u5f97<\/h3>\n<p>Google Analytics\u306e\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u65b9\u6cd5\u306f\u3001\u6b21\u306e\u30b5\u30a4\u30c8\u306b\u307b\u307c\u6cbf\u3063\u3066\u5b9f\u88c5\u3055\u305b\u3066\u3044\u305f\u3060\u3044\u305f\u3002<br \/>\n<a href=\"https:\/\/mistymagich.wordpress.com\/2015\/05\/27\/nodejsjwtjson-web-token%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6analytics-api%E3%81%8B%E3%82%89%E6%9C%88%E9%96%93%E3%83%A6%E3%83%8B%E3%83%BC%E3%82%AF%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BC\/\">Node.js + JWT (JSON Web Token) \u3092\u4f7f\u7528\u3057\u3066 Analytics API \u304b\u3089\u6708\u9593\u30e6\u30cb\u30fc\u30af\u30e6\u30fc\u30b6\u30fc\u6570\u3092\u53d6\u5f97\u3059\u308b | misty-magic.h<\/a><\/p>\n<p>Google Analitics\u306eAPI\u306e\u5229\u7528\u306b\u306f\u3001\u4ee5\u4e0b\u306e\u30b9\u30c6\u30c3\u30d7\u3092\u884c\u3046\u5fc5\u8981\u304c\u3042\u308a\u3001\u5c11\u3057\u9762\u5012\u3060\u3002<\/p>\n<ul>\n<li><a href=\"https:\/\/console.developers.google.com\/project\" target=\"_blank\" rel=\"noopener\">Google Developers Console<\/a>\u3067\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210<\/li>\n<li>Analytics\u3000API\u306e\u6709\u52b9\u5316<\/li>\n<li>\u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210<\/li>\n<li>\u30a2\u30af\u30bb\u30b9\u30ad\u30fc\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9<\/li>\n<li>Google Analytics\u3067\u95b2\u89a7\u6a29\u9650\u306e\u4ed8\u4e0e<\/li>\n<\/ul>\n<p>Node.js\u304b\u3089API\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u3001<a href=\"https:\/\/github.com\/google\/google-api-nodejs-client\" target=\"_blank\" rel=\"noopener\">Google APIs Node.js Client<\/a>\u3068\u3044\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3001 \u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u7bc4\u56f2\u3092\u6307\u5b9a\u3059\u308b\u305f\u3081\u306bJavascript\u3067\u65e5\u4ed8\u3084\u6642\u9593\u3092\u6271\u3046\u306e\u306b\u4fbf\u5229\u306a\u30e2\u30b8\u30e5\u30fc\u30eb\u3001<a href=\"https:\/\/momentjs.com\/\" target=\"_blank\" rel=\"noopener\">Moment.js<\/a>\u3092\u4f7f\u3046\u3002<\/p>\n<p>[code]<br \/>\n$ npm install googleapis &#8211;save<br \/>\n$ npm install moment &#8211;save<br \/>\n[\/code]<\/p>\n<p>\u4ee5\u4e0a\u306e\u30b9\u30c6\u30c3\u30d7\u3092\u7d42\u3048\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u30b3\u30fc\u30c9\u3092\u5b9f\u88c5\u3059\u308b\u3002\u3053\u3053\u3067\u306f\u4f8b\u3068\u3057\u3066\u3001\u6628\u65e5\u306e\u8a2a\u554f\u8005\u6570\u3068\u3001\u30cb\u30e5\u30fc\u30b9\u30ec\u30bf\u30fc\u306e\u767b\u9332\u6570\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u306b\u3059\u308b\u3002\u305d\u3057\u3066\u3001\u96c6\u8a08\u306e\u4f8b\u3068\u3057\u3066\u3001\u8a2a\u554f\u8005\u306e\u3046\u3061\u306e\u3001\u4f55\u4eba\u304c\u30cb\u30e5\u30fc\u30b9\u30ec\u30bf\u30fc\u306b\u767b\u9332\u3057\u305f\u304b\u3092\u8a08\u7b97\u3057\u3066\u307f\u3088\u3046\u3002\u3082\u3061\u308d\u3093\u3001\u5b9f\u969b\u306b\u6539\u5584\u3092\u884c\u3046\u306e\u306b\u306f\u3001\u3082\u3046\u5c11\u3057\u5177\u4f53\u6027\u3092\u6301\u3063\u305f\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u304c\u3001\u3053\u3053\u3067\u306f\u7c21\u5358\u306e\u305f\u3081\u306b\u53d6\u5f97\u3057\u3084\u3059\u304f\u5206\u304b\u308a\u3084\u3059\u3044\u6570\u5024\u306b\u3057\u305f\u3002<\/p>\n<p>\u306a\u304a\u3001fresthrax\u3067\u306f\u3001freshtrax\u6700\u65b0\u8a18\u4e8b\u3001CEO\u306e\u30aa\u30f3\u30e9\u30a4\u30f3\u30bb\u30df\u30ca\u30fc\u306e\u3054\u6848\u5185\u3001\u6700\u65b0\u30b5\u30fc\u30d3\u30b9\u3084\u30a4\u30d9\u30f3\u30c8\u60c5\u5831\u3092\u3044\u3061\u65e9\u304f\u304a\u5c4a\u3051\u3059\u308b\u30cb\u30e5\u30fc\u30b9\u30ec\u30bf\u30fc\u3092\u904b\u55b6\u3057\u3066\u3044\u307e\u3059\u3002\u53f3\u306e\u30b5\u30a4\u30c9\u30d0\u30fc\u304b\u3089\u767b\u9332\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>[javascript]<br \/>\n# freshtrax<br \/>\nGOOGLE_SERVICE_ACCOUNT_KEY_FILE = __dirname + &#8216;\/google-key.json&#8217; # \u30ad\u30fc\u30d5\u30a1\u30a4\u30eb<br \/>\nGOOGLE_SERVICE_ACCOUNT_EMAIL = &#8216;XXX@XXXX&#8217; # \u30b5\u30fc\u30d3\u30b9\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9<br \/>\nGA_VIEW_ID = &#8216;1111111&#8217;  # google analytics\u306eView ID<\/p>\n<p># metrics\u306e\u6307\u5b9a @see https:\/\/developers.google.com\/analytics\/devguides\/reporting\/core\/dimsmets<br \/>\nMETRICS_VISITOR = &#8216;ga:visitors&#8217;<br \/>\nMETRICS_GOAL_NEWS_LETTER_JP = &#8216;ga:goal16Completions&#8217; # ga:goalXXCompletions\u306e\u5f62\u5f0f\u3002XX\u306e\u90e8\u5206\u30921\u304b\u308920\u307e\u3067\u306e\u6570\u5b57\u306b\u5909\u3048\u3066\u5024\u3092\u53d6\u5f97\u3067\u304d\u308b<\/p>\n<p>google = require &#8216;googleapis&#8217;<br \/>\nmoment = require &#8216;moment&#8217;<\/p>\n<p>jwt = new google.auth.JWT GOOGLE_SERVICE_ACCOUNT_EMAIL,<br \/>\n  GOOGLE_SERVICE_ACCOUNT_KEY_FILE,<br \/>\n  null,<br \/>\n  [&#8216;https:\/\/www.googleapis.com\/auth\/analytics.readonly&#8217;]<\/p>\n<p>jwt.authorize (err, result) -&gt;<br \/>\n  # \u30a8\u30e9\u30fc\u304c\u3042\u308b\u5834\u5408\u306f\u30ed\u30b0\u3092\u51fa\u529b\u3057\u3066\u7d42\u4e86<br \/>\n  if err<br \/>\n    console.error err<br \/>\n    process.exit()<\/p>\n<p>  # Analytics\u306b\u5024\u3092\u53d6\u5f97\u3059\u308b<br \/>\n  getDataOfYesterday()<\/p>\n<p># \u6628\u65e5\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u30ed\u30b0\u306b\u51fa\u529b\u3059\u308b\u95a2\u6570<br \/>\ngetDataOfYesterday = () -&gt;<br \/>\n  analytics = google.analytics &#8216;v3&#8217;<br \/>\n  yesterdayStr = moment().subtract(1, &#8216;days&#8217;).format(&#8216;YYYY-MM-DD&#8217;)<br \/>\n  params = {<br \/>\n    &#8216;ids&#8217;:        &#8216;ga:&#8217; + GA_VIEW_ID<br \/>\n    &#8216;start-date&#8217;: yesterdayStr<br \/>\n    &#8216;end-date&#8217;:   yesterdayStr<br \/>\n    &#8216;metrics&#8217;:    METRICS_VISITOR + &#8216;,&#8217; + METRICS_GOAL_NEWS_LETTER_JP<br \/>\n    &#8216;auth&#8217;:       jwt<br \/>\n  }<br \/>\n  analytics.data.ga.get params, (err, resp) -&gt;<\/p>\n<p>    # \u30a8\u30e9\u30fc\u304c\u3042\u308b\u5834\u5408\u306f\u30ed\u30b0\u3092\u51fa\u529b\u3057\u3066\u7d42\u4e86<br \/>\n    if err<br \/>\n      console.error err<br \/>\n      process.exit()<\/p>\n<p>\t# \u30a8\u30e9\u30fc\u304c\u306a\u3044\u5834\u5408\u306f\u5024\u3092\u30ed\u30b0\u306b\u51fa\u529b<br \/>\n    visitorCount = resp.totalsForAllResults[METRICS_VISITOR]<br \/>\n    newsLetterCount = resp.totalsForAllResults[METRICS_GOAL_NEWS_LETTER_JP]<\/p>\n<p>    msg = &#8216;freshtrax statics\\n&#8217;<br \/>\n    msg += &#8216;[Yesterday]\\n&#8217;<br \/>\n    msg += &#8216;Users: &#8216; + visitorCount + &#8216;\\n&#8217;<br \/>\n    msg += &#8216;NEWS_LETTER_JP: &#8216; + newsLetterCount + &#8216;\\n&#8217;<br \/>\n    msg += &#8216;Conversion Rate: &#8216; + (newsLetterCount \/ visitorCount * 100).toFixed(2)+ &#8216;%\\n&#8217;<\/p>\n<p>    console.log msg<br \/>\n[\/javascript]<\/p>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u5024\u304c\u51fa\u529b\u3055\u308c\u308b\u3002<\/p>\n<p>[code]<br \/>\n$ coffee ga.coffee<br \/>\nfreshtrax statics<br \/>\n[Yesterday]<br \/>\nUsers: 5137<br \/>\nNEWS_LETTER_JP: 11<br \/>\nConversion Rate: 0.21%<br \/>\n[\/code]<\/p>\n<p>\u69d8\u3005\u306a\u5024\u3092\u3001\u69d8\u3005\u306a\u6761\u4ef6\u3067\u53d6\u5f97\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3002\u4ee5\u4e0b\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u307b\u3057\u3044\u3002\u3061\u306a\u307f\u306b\u30da\u30fc\u30b8\u30d3\u30e5\u30fc\u306f\u3001ga:pageviews\u3067\u53d6\u308c\u308b\u3002<br \/>\n<a href=\"https:\/\/developers.google.com\/analytics\/devguides\/reporting\/core\/dimsmets\" target=\"_blank\" rel=\"noopener\">Dimensions &amp; Metrics Explorer<\/a><\/p>\n<h3>Slack\u3078\u306e\u6295\u7a3f<\/h3>\n<p>Node\u306e<a href=\"https:\/\/github.com\/slackhq\/node-slack-client\" target=\"_blank\" rel=\"noopener\">slack client<\/a>\u3068\u3044\u3046\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3046\u3002npm\u3067\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u7ba1\u7406\u3059\u308b\u3002npm\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u5165\u308c\u308b\u6642\u3082\u3001&#8211;save \u3092\u3064\u3051\u308b\u3053\u3068\u3067\u3001package.json\u306b\u53cd\u6620\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<p>[code]<br \/>\n$ npm install<br \/>\n&#8230; (\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u540d\u306a\u3069\u306f\u9069\u5f53)<br \/>\n$ npm install slack-client &#8211;save<br \/>\n[\/code]<\/p>\n<p>Slack\u306e\u30dc\u30c3\u30c8\u7528\u306e\u30c8\u30fc\u30af\u30f3\u306e\u53d6\u5f97\u3068\u3001\u6295\u7a3f\u5148\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u306eID\u304c\u5fc5\u8981\u306b\u306a\u308b\u3002\u3053\u308c\u3089\u306e\u53d6\u5f97\u306f\u7c21\u5358\u306b\u884c\u3048\u3001\u3059\u3067\u306b\u591a\u6570\u306e\u30b5\u30a4\u30c8\u3067\u7d39\u4ecb\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3053\u3053\u3067\u306f\u7d39\u4ecb\u3057\u306a\u3044\u3002slack-client\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u901a\u308a\u306b\u9032\u3081\u308b\u3068\u7c21\u5358\u306b\u63a5\u7d9a\u3067\u304d\u308b\u3002<\/p>\n<p>ga.coffee<\/p>\n<p>[javascript]<br \/>\nSlack = require &#8216;slack-client&#8217;<br \/>\nSLACK_CHANNEL_ID = &#8216;&lt;\u30c1\u30e3\u30f3\u30cd\u30ebID&gt;&#8217; # \u5bfe\u8c61\u306e\u30c1\u30e3\u30f3\u30cd\u30eb\u306eID<br \/>\nSLACK_TOKEN = &#8216;&lt;Slack\u306e\u30dc\u30c3\u30c8\u306e\u30c8\u30fc\u30af\u30f3&gt;&#8217; # slack\u306e\u30dc\u30c3\u30c8\u306e\u30c8\u30fc\u30af\u30f3<\/p>\n<p>autoReconnect = true # \u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u305f\u6642\u306b\u518d\u63a5\u7d9a\u3059\u308b\u304b\u3069\u3046\u304b<br \/>\nautoMark = true # \u6295\u7a3f\u3092\u65e2\u8aad\u306b\u3059\u308b\u304b\u3069\u3046\u304b<\/p>\n<p>slack = new Slack(SLACK_TOKEN, autoReconnect, autoMark)<\/p>\n<p># \u63a5\u7d9a\u306e\u78ba\u7acb\u6642\u306b\u547c\u3070\u308c\u308b<br \/>\nslack.on &#8216;open&#8217;, -&gt;<br \/>\n\tconsole.log &quot;Connected to #{slack.team.name} as @#{slack.self.name}&quot;<\/p>\n<p># \u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u6295\u7a3f\u3055\u308c\u308b\u3068\u547c\u3070\u308c\u308b<br \/>\nslack.on &#8216;message&#8217;, (message) -&gt;<\/p>\n<p>\tchannel = slack.getChannelGroupOrDMByID message.channel<br \/>\n\tuser = slack.getUserByID message.user<br \/>\n\ttext = message.text<br \/>\n\tconsole.log &quot;received message #{text} in channel #{channel.name}&quot;<\/p>\n<p>slack.on &#8216;error&#8217;, (err) -&gt;<br \/>\n\tconsole.error &quot;Error&quot;, err<\/p>\n<p>slack.login()<br \/>\n[\/javascript]<\/p>\n<p>\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001 &#8216;open&#8217;\u304c\u547c\u3070\u308c\u305f\u5f8c\u3001\u4ed6\u306e\u30a4\u30d9\u30f3\u30c8\u3092\u53d7\u3051\u4ed8\u3051\u308b\u72b6\u614b\u306b\u306a\u308b\u3002<\/p>\n<p>[code]<br \/>\n$ coffee slack.coffee<br \/>\n[Wed Dec 02 2015 16:09:16 GMT-0800 (PST)] INFO Connecting&#8230;<br \/>\nConnected to btrax as @test-bot<br \/>\n[\/code]<\/p>\n<p>\u4f8b\u3048\u3070\u3001\u300cfreshtrax\u300d\u3068slack\u3067\u6295\u7a3f\u3059\u308b\u3068\u3001message\u306e\u30a4\u30d9\u30f3\u30c8\u304c\u547c\u3070\u308c\u3066\u30ed\u30b0\u304c\u5410\u304d\u51fa\u3055\u308c\u308b\u3002<\/p>\n<p>[code]<br \/>\nreceived message freshtrax in channel slack_hacking<br \/>\n[\/code]<\/p>\n<h3>Google Analytics\u306e\u5024\u3092Slack\u306b\u6295\u7a3f\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u88c5<\/h3>\n<p>Google Analytics\u306e\u5024\u3092\u53d6\u3063\u3066\u304f\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u6700\u5f8c\u306b\u30ed\u30b0\u51fa\u529b\u3057\u3066\u3044\u308b\u90e8\u5206\u3067\u3001Slack\u306b\u6295\u7a3f\u3059\u308b\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308c\u3070\u826f\u3044\u3002<\/p>\n<p>\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u304c\u6df1\u304f\u306a\u308b\u304c\u3001\u51e6\u7406\u3068\u3057\u3066\u306f\u3001<br \/>\n1. Slack\u3067\u30ed\u30b0\u30a4\u30f3\u3059\u308b<br \/>\n2. Google analytics\u306b\u30ed\u30b0\u30a4\u30f3\u3057\u3001\u5024\u3092\u53d6\u5f97\u3059\u308b<br \/>\n3. Slack\u306b\u6295\u7a3f\u3059\u308b<\/p>\n<p>\u306e\u9806\u5e8f\u3067\u5b9f\u884c\u3055\u305b\u308b\u3002\u3053\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6bce\u65e5\u5b9a\u671f\u7684\u306b\u5b9f\u884c\u3055\u305b\u308c\u3070\u826f\u3044\u3002<\/p>\n<p>\u307e\u305f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bSlack\u306emessage\u53d7\u4fe1\u6642\u306e\u30a4\u30d9\u30f3\u30c8\u3067\u5b9f\u884c\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u308b\u3002\u30e1\u30c3\u30bb\u30fc\u30b8\u306e\u30a4\u30d9\u30f3\u30c8\u5185\u3067\u3001\u30c1\u30e3\u30f3\u30cd\u30eb\u3068\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u5224\u5b9a\u3059\u308b\u3002\u6307\u5b9a\u3057\u305f\u30c1\u30e3\u30f3\u30cd\u30eb\u5185\u3067\u3001\u6307\u5b9a\u3057\u305f\u6587\u8a00\u306e\u6642\u306b\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n<p>[javascript]<br \/>\nslack.on &#8216;message&#8217;, (message) -&gt;<\/p>\n<p>  channel = slack.getChannelGroupOrDMByID message.channel<br \/>\n  user = slack.getUserByID message.user<br \/>\n  text = message.text<\/p>\n<p>  console.log &quot;received message #{text} in channel #{channel.name}&quot;<\/p>\n<p>  # slack_hacking \u30c1\u30e3\u30f3\u30cd\u30eb\u3067\u3001freshtrax\u3068\u5165\u529b\u3057\u305f\u6642\u306b\u60c5\u5831\u3092\u8868\u793a\u3059\u308b\u3002<br \/>\n  if text is &#8216;freshtrax&#8217; and channel.name is &#8216;slack_hacking&#8217;<br \/>\n    getDataOfYesterday()<\/p>\n<p>[\/javascript]<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-32648\" src=\"https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack.jpg\" alt=\"ga-slack\" width=\"715\" height=\"200\" srcset=\"https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack.jpg 715w, https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack-300x84.jpg 300w, https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack-704x197.jpg 704w, https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack-705x197.jpg 705w, https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack-341x95.jpg 341w, https:\/\/blog.btrax.com\/jp\/wp-content\/uploads\/sites\/3\/2015\/12\/ga-slack-624x175.jpg 624w\" sizes=\"auto, (max-width: 715px) 100vw, 715px\" \/><\/p>\n<p>\u3042\u3068\u306f\u3001Heroku\u306b\u30c7\u30d7\u30ed\u30a4\u3057\u3066Heroku Scheduler\u3092\u4f7f\u3063\u3066\u5b9a\u671f\u5b9f\u884c\u3055\u305b\u3066\u3082\u826f\u3044\u3057\u3001<br \/>\n\u64ec\u4f3c\u7684\u306acron\u3092\u4f7f\u3048\u308b\u3001<a href=\"https:\/\/github.com\/ncb000gt\/node-cron\" target=\"_blank\" rel=\"noopener\">node-cron<\/a>\u3067\u5b9f\u884c\u3055\u305b\u3066\u3082\u3088\u3044\u3002<\/p>\n<p>\u30bd\u30fc\u30b9\u30b3\u30fc\u30c9\u3082\u516c\u958b\u3057\u3066\u3044\u307e\u3059\u3002<a href=\"https:\/\/github.com\/btrax\/ga_slack\" target=\"_blank\" rel=\"noopener\">\u3053\u3061\u3089\u304b\u3089<\/a><\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Web\u30b5\u30a4\u30c8\u3084\u30a2\u30d7\u30ea\u306f\u3001\u554f\u8005\u6570\u306f\u3082\u3061\u308d\u3093\u30da\u30fc\u30b8\u5358\u4f4d\u306e\u95b2\u89a7\u6642\u9593\u306e\u5e73\u5747\u306a\u3069\u3055\u3089\u306b\u306f\u4f55\u4eba\u306e\u4eba\u304c\u30dc\u30bf\u30f3\u3092\u30af\u30ea\u30c3\u30af\u3057\u305f\u304b\u306a\u3069\u30e6\u30fc\u30b6\u30fc\u306e\u591a\u304f\u306e\u884c\u52d5\u3092\u8a18\u9332\u3067\u304d\u308b\u3002 \u4ee3\u8868\u7684\u306a\u30c4\u30fc\u30eb\u306fGoogle\u304c\u63d0\u4f9b\u3059\u308bGoogle Analytics [&hellip;]<\/p>\n","protected":false},"author":80,"featured_media":32695,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[230],"tags":[212],"class_list":["post-32523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-212"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/posts\/32523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/users\/80"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/comments?post=32523"}],"version-history":[{"count":10,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/posts\/32523\/revisions"}],"predecessor-version":[{"id":55357,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/posts\/32523\/revisions\/55357"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/media\/32695"}],"wp:attachment":[{"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/media?parent=32523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/categories?post=32523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.btrax.com\/jp\/wp-json\/wp\/v2\/tags?post=32523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}