title: Calculate Previous Page Path in BigQuery
body: <p>I am pulling data for a homepage heat map and I would like to only see <em>pageviews</em> where the previous page was the homepage.</p>
  
  <p>My data is imported Google Analytics tables - the metric 'previous page path' does not exist in BQ, so how would I go about working it out?</p>
  
  <p>Here is a basic example of my query:</p>
  
  <pre><code>SELECT
    hits.page.pagePath
  FROM (TABLE_DATE_RANGE([***.ga_sessions_],
        DATE_ADD(CURRENT_TIMESTAMP(), -4, 'DAY'),
        DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY')))
  WHERE ? -- Where previous page path was the homepage?
  GROUP BY hits.page.pagePath
  </code></pre>
  
  <p>What could I use in the WHERE clause to define the previous page path?</p>