Finding the Customer journey (channels) made by users in Google BigQuery

荒凉一梦 提交于 2019-12-21 06:35:32

问题


I'm looking to find the Customer Journey user's made via the Online Marketing Channels. The schema of my dataset is the same as Google Merchandise Store, which can be found here: https://support.google.com/analytics/answer/3437719?hl=en

This is how my input data looks like (example):

+---------------+-------+------------+---------+--------------+-------------+
| fullVisitorId | visit | visitTime  | revenue | transactions |   channel   |
+---------------+-------+------------+---------+--------------+-------------+
|          1234 |     1 | 1516468217 | null    | null         | Direct      |
|          1234 |     2 | 1517937012 | null    | null         | EMail       |
|          1234 |     3 | 1523031014 | null    | null         | Organic     |
|          1234 |     4 | 1530461419 | null    | null         | Organic     |
|          1234 |     5 | 1531152611 | null    | null         | Paid Search |
|          1234 |     6 | 1531411812 | 1393000 | 1            | Organic     |
+---------------+-------+------------+---------+--------------+-------------+

I already did this SQL Query:

WITH
_step1 AS (SELECT
DISTINCT
a.fullVisitorId, 
a.visitNumber,
a.visitStartTime,
a.Date,
a.totals.totalTransactionRevenue AS totalTransactionRevenue,
a.totals.transactions AS transactions,
a.channelGrouping AS channelGrouping

FROM
`data` a,
unnest(a.hits) as h
)
SELECT
a.fullVisitorId as visitor,
STRING_AGG(channelGrouping, '>') AS CustomerJourney, 
SUM(totalTransactionRevenue) AS Umsatz, 
SUM(transactions) AS transaktionen
FROM
_step1 as s

GROUP BY fullVisitorId

The results should look like:

+--------+----------------------------+---------+---------------+
| visitor| CustomerJourney            | Umsatz  | transaktionen |
+--------+----------------------------+---------+---------------+
|1234    | Direct>EMail               | null    | null          |
|1234    | Organic                    | null    | null          |
|1234    | Organic>Paid Search>Organic| 1393000 | 1             |
+--------+----------------------------+---------+---------------+

What i actually get:

+--------+-------------------------------------------------+---------+---------------+
| visitor| CustomerJourney                                 | Umsatz  | transaktionen |
+--------+-------------------------------------------------+---------+---------------+
|1234    | Direct>EMail>Organic>Organic>Paid Search>Organic|1393000  |1              |
+--------+-------------------------------------------------+---------+---------------+

The difficult part:

There is a conversion tracking period (30 days), which means that a new customer journey will start if 30 days have elapsed since the first visit or if the user has completed a transaction (a new Row). There are Timestamps for every visit.

Which query must I start to consider the conversion tracking period?

来源:https://stackoverflow.com/questions/54196418/finding-the-customer-journey-channels-made-by-users-in-google-bigquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!