title: Importing Facebook API data as JSON Object into Google Sheets results in mismatched Dates value
body: <p><strong>Goal:</strong> Import client data from Facebook Graph API into a Google Sheet to create a dynamic Facebook Ads Dashboard</p>
  <p><strong>What I've tried:</strong></p>
  <ol>
  <li><p>Downloaded Google Sheet script that includes an ImportJSON function which is meant to import a JSON feed and flatten it into a two-dimensional array <a href="https://github.com/bradjasper/ImportJSON" rel="nofollow noreferrer">ImportJSON</a></p>
  </li>
  <li><p>Used ImportJSON with a Graph API query created by Faceook's Graph API Explorer. That looks something like this:</p>
  </li>
  </ol>
  <p><code>/insights?date_preset=lifetime&amp;time_increment=1&amp;fields=account_currency,spend,frequency,reach,impressions,actions,cpm&amp;use_account_attribution_setting=true&amp;limit=5000</code></p>
  <p><strong>Result:</strong> Returns 2d-array in Google Sheet filled with the data we want. So far so good.</p>
  <p><strong>Problem:</strong> The dates are all off by one day (one day behind) for the values associated with query field &quot;actions&quot;</p>
  <p>Query field &quot;actions&quot; returns an object with key &quot;actions&quot; and a value which is an array of objects whose keys and values correspond to different kinds of actions users are taking in response to our ads.</p>
  <p>All of these are behind by one day.</p>
  <p><strong>My Investigation:</strong>
  <a href="https://i.stack.imgur.com/q4Eh2.png" rel="nofollow noreferrer">Google Sheets Output</a></p>
  <pre><code>  &quot;data&quot;: [
      {
        &quot;account_currency&quot;: &quot;USD&quot;,
        &quot;spend&quot;: &quot;14.76&quot;,
        &quot;frequency&quot;: &quot;1.263227&quot;,
        &quot;reach&quot;: &quot;4593&quot;,
        &quot;impressions&quot;: &quot;5802&quot;,
        &quot;cpm&quot;: &quot;2.54395&quot;,
        &quot;actions&quot;: [
          {
            &quot;action_type&quot;: &quot;onsite_conversion.messaging_first_reply&quot;,
            &quot;value&quot;: &quot;2&quot;
          },
          {
            &quot;action_type&quot;: &quot;onsite_conversion.view_content&quot;,
            &quot;value&quot;: &quot;4&quot;
          },
          {
            &quot;action_type&quot;: &quot;onsite_conversion.messaging_conversation_started_7d&quot;,
            &quot;value&quot;: &quot;19&quot;
          },
          {
            &quot;action_type&quot;: &quot;comment&quot;,
            &quot;value&quot;: &quot;1&quot;
          },
          {
            &quot;action_type&quot;: &quot;link_click&quot;,
            &quot;value&quot;: &quot;45&quot;
          },
          {
            &quot;action_type&quot;: &quot;offsite_conversion.fb_pixel_custom&quot;,
            &quot;value&quot;: &quot;1&quot;
          },
          {
            &quot;action_type&quot;: &quot;offsite_conversion.fb_pixel_view_content&quot;,
            &quot;value&quot;: &quot;1&quot;
          },
          {
            &quot;action_type&quot;: &quot;post&quot;,
            &quot;value&quot;: &quot;5&quot;
          },
          {
            &quot;action_type&quot;: &quot;post_reaction&quot;,
            &quot;value&quot;: &quot;25&quot;
          },
          {
            &quot;action_type&quot;: &quot;omni_view_content&quot;,
            &quot;value&quot;: &quot;5&quot;
          },
          {
            &quot;action_type&quot;: &quot;page_engagement&quot;,
            &quot;value&quot;: &quot;76&quot;
          },
          {
            &quot;action_type&quot;: &quot;post_engagement&quot;,
            &quot;value&quot;: &quot;76&quot;
          },
          {
            &quot;action_type&quot;: &quot;view_content&quot;,
            &quot;value&quot;: &quot;1&quot;
          }
        ],
        &quot;date_start&quot;: &quot;2020-11-04&quot;,
        &quot;date_stop&quot;: &quot;2020-11-04&quot;
      },
      {
        &quot;account_currency&quot;: &quot;USD&quot;,
        &quot;spend&quot;: &quot;21.61&quot;,
        &quot;frequency&quot;: &quot;1.249471&quot;,
        &quot;reach&quot;: &quot;6145&quot;,
        &quot;impressions&quot;: &quot;7678&quot;,
        &quot;cpm&quot;: &quot;2.814535&quot;,
        &quot;actions&quot;: [
          {
            &quot;action_type&quot;: &quot;onsite_conversion.messaging_first_reply&quot;,
            &quot;value&quot;: &quot;1&quot;
          },
          {
            &quot;action_type&quot;: &quot;onsite_conversion.messaging_conversation_started_7d&quot;,
            &quot;value&quot;: &quot;13&quot;
  </code></pre>
  <p>When I look at the sample of my JSON attached and compare it to the Google Sheets output, it looks to me like the &quot;actions&quot; keys and values are inheriting the &quot;date_start&quot; and &quot;date_stop&quot; values of the <strong>prior object</strong> and that is what is throwing my data off.</p>
  <p><strong>Question:</strong> Have I diagnosed this correctly? If so, how can ensure the &quot;actions&quot; are associated with the correct date?</p>
  <p>Thanks for reading this. I hope my problem is described clearly.</p>
  <p>I'm teaching myself this stuff so my vocabulary is probably a little shoddy!</p>