title: google analytics core api results sampling level
body: <p>I have a script pulling data from the Google Analytics core api. Since I am using the results of the data to successfully populate a sheet in GSheets I know that my data pull is a success.</p>
  
  <p>I'm reading the documentation <a href="https://developers.google.com/analytics/devguides/reporting/core/v3/reference" rel="nofollow noreferrer">here</a>.</p>
  
  <p>In particular, this table:
  <img src="https://i.stack.imgur.com/CtQL8.png" alt="enter image description here"></p>
  
  <p>However, I would like to Logger.log() the sampling level of the query:</p>
  
  <pre><code>// check sampling for each report
      if(!results.containsSampledData) {
        Logger.log('sampling: none');
      } else {
        Logger.log('sampling: ' + results.query.samplingLevel);
      }
  </code></pre>
  
  <p>When I view the logs I get 'sampling: undefined'.</p>
  
  <p>How do I get the sampling results from the results object?</p>
  
  <p>Here is what generates the results object, though I don;t think it's relavant (but may be wrong):</p>
  
  <pre><code>// get GA data from core api
  function getReportDataForProfile(profile, len_results, start_num) {
    var startDate = getLastNdays(30); // set date range here
    var endDate = getLastNdays(0);
  
    var optArgs = {
      'dimensions': 'ga:dimension5, ga:dimension4', // Comma separated list of dimensions.
      'start-index': start_num,
      'max-results': len_results,
      'filters': 'ga:source==cj'
    };
  
        // Make a request to the API.
        var results = Analytics.Data.Ga.get( // mcf for multi channel api, Ga for core
            profile,                    // Table id (format ga:xxxxxx).
            startDate,                  // Start-date (format yyyy-MM-dd).
            endDate,                    // End-date (format yyyy-MM-dd).
            'ga:goalCompletionsAll, ga:users, ga:sessions', // Comma seperated list of metrics.
            optArgs);
  
        return results;
      }
  </code></pre>