In Analytics 360 there's a way to go into Behavior > Site Content > Landing Page > Add New Segment > Sequences
and then you can define a sequence of events, say, user goes from page 1 and then goes to page 2 and then searches and then... etc.
I want to be able to pull this data via the GA API v4 using python's googleapiclient.discovery
. I can do these queries with dimensions and metrics, but I am not sure how to set up a sequence. Here's how I query dimensions and metrics:
request = {
'viewId': view_id',
'dateRanges': {
'startDate': datetime.strftime(pd.to_datetime('2018-12-01'),'%Y-%m-%d'),
'endDate': datetime.strftime(pd.to_datetime('2018-12-31'),'%Y-%m-%d')
},
'dimensions': [
{'name':'ga:date'}
],
'metrics': [{'expression': 'ga:sessions'}]
}
Then I was looking here and it seemed like the call could be sequenceSegment
but that was not recognized. And here it seems to go into it but not in the way googleapiclient.discovery
describes it.
I'm just a bit lost how to query the sequences report.
You can do this by using the segments in the API-Call. In the API-Call you have to specify the "sequence Segment" you want to apply on the data (or you take a predefined Segment from the UI by calling it by ID).
https://developers.google.com/analytics/devguides/reporting/core/v3/segments#conditions-vs-sequences
users::sequence::ga:deviceCategory==desktop;->>ga:deviceCategory==mobile
So if I want all Sessions from Users with dimension date triggering Event Category A and after this coming to pagePath B it would look like this (R):
google_analytics_4(
"ID",
start = '2019-03-18',
end = '2019-03-18',
metrics = c("sessions"),
dimensions = c("date"),
segments = c("sessions::sequence::ga:eventCategory==A;->>ga:pagePath==B"),
max_results = 99999999
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.