Googleアナリティクス、ロングテールSEOチェッカー

Google Apps Script

キーワードの種類数を取得します。

◆テールを狙うならチェックしたい指標

キーワードの種類やLPの数は、入り口増を狙うサイト運営者の重要指標です。

現状のGoogleアナリティクスでは、日付ごとにそれらを追うにはちょっと面倒なので、Google Apps Script を組んでみました。

結構、適当な変数名やハードコーディング、以前のコードが消しきれてないなどかなり恥ずかしいので、気が変わったらエントリー消すかもしれませんので、ご容赦を。

あとは、これをcronで自動実行させて(Google Apps Script の自動実行機能)、シート保存やメール送信などさせると良いかと思います。

参考になれば幸いです。

/*
* @title Google Analytics Longtail SEO Checker
* @description This script is very simple.
* //www.kagua.biz
* @license Yoshihiko Yoshida
*/

//メニュー
function onOpen(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var menus = [{name: 'データ取得', functionName: 'myFunction'},
];
ss.addMenu('アナリティクス', menus);
}

//メイン
function myFunction() {

//シートクリア
var url=SpreadsheetApp.getActiveSpreadsheet().getUrl();
spkey=url.split("key=");
if (spkey.length > 0) {
spkey=spkey[1];
}
ss = SpreadsheetApp.openById(spkey);
sheet = ss.getSheetByName("Sheet1");
var cell = sheet.getRange("A2");
for( var i=0 ;i<8;i++){ for( var j=0 ;j<31;j++){ cell.offset(j, i).setValue( "" ); } } var aaa = new Array(11); for (var i=0 ; i < aaa.length; i ++) {aaa[i]=0;} //日付 M2とM3を指標によって場所を変えて下さい //スプレッドシートのurlからシートIDを貼り付ける sheet = ss.getSheetByName("Sheet1"); var GAa = sheet.getRange('M2').getValue(); var BBkaishi = GAa; var GAyear = GAa.getFullYear(); // 年 var GAmon = GAa.getMonth() + 1; // 月 var GAday = GAa.getDate(); // 日 if (GAmon < 10) { GAmon = '0' + GAmon;} if (GAday < 10) { GAday = '0' + GAday;} var GAb = "" + GAyear + "-" + GAmon + "-" + GAday; var GAa = sheet.getRange('M3').getValue(); var BBshuuryou = GAa; var GAyear = GAa.getFullYear(); // 年 var GAmon = GAa.getMonth() + 1; // 月 var GAday = GAa.getDate(); // 日 if (GAmon < 10) { GAmon = '0' + GAmon;} if (GAday < 10) { GAday = '0' + GAday;} var GAc = "" + GAyear + "-" + GAmon + "-" + GAday; //日付生成ルーチン var BBhiduke = new Array(); var BB1 = BBshuuryou.getTime(); var BB2 = BBkaishi.getTime(); var BBkikan = Math.round( ( BB1 - BB2 ) / (24*60*60*1000) ) ; for ( var i=1 ; i <= BBkikan ; i++){ BB2 = BB2 + 24*60*60*1000; today = new Date( BB2 ); var GAyear = today.getFullYear(); // 年 var GAmon = today.getMonth() + 1; // 月 var GAday = today.getDate(); // 日 if (GAmon < 10) { GAmon = '0' + GAmon;} if (GAday < 10) { GAday = '0' + GAday;} BBhiduke[i] = "" + GAyear + "-" + "" + GAmon + "-" + "" + GAday; } BBhiduke[0] = GAb; //日付入れるルーチン終了 var PN = new Array( "01_VIEW" ); //プロパティIDを入れる var PF = new Array( "ga:xxxxxxxxxx" ); PF[0] = sheet.getRange('M4').getValue(); //◆KW数 var BBkeyword = { 'dimensions': 'ga:keyword', 'segment': 'dynamic::ga:medium==organic', 'max-results': '1000' }; //◆LP数 var BBlandingpage = { 'dimensions': 'ga:landingPagePath', 'segment': 'dynamic::ga:medium==organic', 'max-results': '1000' }; //取得ルーチン for ( k=0 ; k

・ ・ ・ ・ ・

>>安っ!アマゾンで半額以下になっている食品タイムセール
セール特設ページを見る

↓↓↓無料のニュースレターを配信中です

GoogleアナリティクスAPIコンソールも忘れずに。