|
@@ -62,7 +62,9 @@ class IndexController extends Controller
|
|
|
public function actionSynsdata(){
|
|
|
$ga=new GA();
|
|
|
$store="supernova";
|
|
|
+ // $start_day=
|
|
|
$data=$ga->trafficsource($store);
|
|
|
+ $this->addSource($data,$store);
|
|
|
exit;
|
|
|
// $contentpages=$ga->contentpages($store);
|
|
|
// $this->addContentpages($contentpages,$store);
|
|
@@ -70,6 +72,65 @@ class IndexController extends Controller
|
|
|
|
|
|
|
|
|
}
|
|
|
+ public function addSource($data,$store){
|
|
|
+ $i=1;
|
|
|
+ $limit=200;
|
|
|
+ $modelKey=[
|
|
|
+ 'date',
|
|
|
+ 'store',
|
|
|
+ 'source',
|
|
|
+ 'channelGrouping',
|
|
|
+ 'landingPagePath',
|
|
|
+ 'keyword',
|
|
|
+ 'socialNetwork',
|
|
|
+ 'users',
|
|
|
+ 'newUsers',
|
|
|
+ 'sessions',
|
|
|
+ 'bounceRate',
|
|
|
+ 'pageviewsPerSession',
|
|
|
+ 'avgSessionDuration',
|
|
|
+ 'transactionsPerVisit',
|
|
|
+ 'transactions',
|
|
|
+ 'transactionRevenue',
|
|
|
+ 'created_at',
|
|
|
+ ];
|
|
|
+ if(!empty($data)){
|
|
|
+ $list=[];
|
|
|
+ foreach($data as $k=>$v){
|
|
|
+ $item=[
|
|
|
+ date('Y-m-d',strtotime($v['date'])),
|
|
|
+ $store,
|
|
|
+ $v['source'],
|
|
|
+ $v['channelGrouping'],
|
|
|
+ $v['landingPagePath']!=="(not set)"?$v["landingPagePath"]:"",
|
|
|
+ $v['keyword']!=="(not set)"?$v['keyword']:"",
|
|
|
+ $v['socialNetwork']!=="(not set)"?$v['socialNetwork']:"",
|
|
|
+ $v['users'],
|
|
|
+ $v['uniquePageviews'],
|
|
|
+ $v['sessions'],
|
|
|
+ $v['bounceRate'],
|
|
|
+ $v['pageviewsPerSession'],
|
|
|
+ $v['avgSessionDuration'],
|
|
|
+ $v['transactionsPerVisit'],
|
|
|
+ $v['transactions'],
|
|
|
+ $v['transactionRevenue'],
|
|
|
+ time(),
|
|
|
+ ];
|
|
|
+ $list[]=$item;
|
|
|
+ if($i%$limit==0||$i==count($data)){
|
|
|
+ echo "<pre>";
|
|
|
+ print_r($list);exit;
|
|
|
+ \Yii::$app->db->createCommand()->batchInsert(Trafficsource::tableName(), $modelKey, $list)->execute();
|
|
|
+ $list=[];
|
|
|
+ }
|
|
|
+ $i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public function addContentpages($contentpages,$store){
|
|
|
$i=1;
|
|
|
$limit=20;
|