dimanche 1 décembre 2019

Google Analytics Reporting API Failed to get Unique Page Views

I am using Google Analytics Reporting API v4 to get my analytics data, I am following the same steps, where creating Views and adding my site as well, but it is not working, I have my subdomain site like abcd.xyz.com

Nd I am hitting site by different valid IP addresses yet it is not giving any results to show in dashboard.

Is there anything to keep on my homepage or site so that Google Analytics knows that this website has been HIT?

I have heard about gTag but still I kept at home page but failed to achieven any results:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  //gtag('config', 'GA_MEASUREMENT_ID');
  gtag('config', 'GA_MEASUREMENT_ID', {
  'page_title' : 'homepage',
  'page_path': '/'
});
</script>

My Google Reporting API Code where I am fetching the data:

$VIEW_ID = "viewid";

  // Create the DateRange object.
  $dateRange = new Google_Service_AnalyticsReporting_DateRange();
  $dateRange->setStartDate("7daysAgo");
  $dateRange->setEndDate("today");

  // Create the Metrics object.
  $sessions = new Google_Service_AnalyticsReporting_Metric();
  $sessions->setExpression("ga:sessions");
  $sessions->setAlias("sessions");

  // Create the ReportRequest object.
  $request = new Google_Service_AnalyticsReporting_ReportRequest();
  $request->setViewId($VIEW_ID);
  $request->setDateRanges($dateRange);
  $request->setMetrics(array($sessions));

  $body = new Google_Service_AnalyticsReporting_GetReportsRequest();
  $body->setReportRequests( array( $request) );
  return $analytics->reports->batchGet( $body );

I even looked into my google analytics dashboard but failed to get results.

Is something missing with the flow.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire