Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
import of multiple search types was not working, fixed now
  • Loading branch information
PromInc committed Aug 28, 2015
1 parent 74f8a47 commit 3397218
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions inc/code/dataCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function checkNeededDataGoogleSearchAnalytics($website) {


public function downloadGoogleSearchAnalytics($website,$date) {
$importCount = 0;
/* Website requires a trailing slash */
// if( substr( $website, -1 ) != "/" ) { $website .= "/"; }

Expand All @@ -88,32 +89,27 @@ public function downloadGoogleSearchAnalytics($website,$date) {

/* Build Search Analytics Request */
$searchAnalyticsRequest->setDimensions(['query','device']);
// $searchAnalyticsRequest->setDimensions( array('query','device') );
$searchAnalyticsRequest->setRowLimit( 5000 ); /* Valid options: 1-5000 */

/* Loop through each of the dates requested */
/* foreach( $dateList as $dateListIndex => $date ) { */

/* Set date for Search Analytics Request */
$searchAnalyticsRequest->setStartDate( $date );
$searchAnalyticsRequest->setEndDate( $date );
/* Loop through each of the search types */
foreach( $searchTypes as $searchTypesIndex => $searchType ) {

/* Set search type in Search Analytics Request */
$searchAnalyticsRequest->setSearchType( $searchType );

/* Send Search Analytics Request */
$searchAnalyticsResponse = $searchanalytics->query( $website, $searchAnalyticsRequest);

/* Import Search Analytics to Database */
if( is_object( $searchAnalyticsResponse ) ) {
$wmtimport = new WMTimport();

return $wmtimport->importGoogleSearchAnalytics( $website, $date, $searchType, $searchAnalyticsResponse );
}
/* Set date for Search Analytics Request */
$searchAnalyticsRequest->setStartDate( $date );
$searchAnalyticsRequest->setEndDate( $date );
/* Loop through each of the search types */
foreach( $searchTypes as $searchType ) {
/* Set search type in Search Analytics Request */
$searchAnalyticsRequest->setSearchType( $searchType );

/* Send Search Analytics Request */
$searchAnalyticsResponse = $searchanalytics->query( $website, $searchAnalyticsRequest);

/* Import Search Analytics to Database */
if( is_object( $searchAnalyticsResponse ) ) {
$wmtimport = new WMTimport();
$importCount += $wmtimport->importGoogleSearchAnalytics( $website, $date, $searchType, $searchAnalyticsResponse );
}
/* } */
}

return $importCount;

}

Expand Down

0 comments on commit 3397218

Please sign in to comment.