- HTTP request
- Request body
- Response body
- Authorization Scopes
- User
- UserIdType
- ActivityType
- UserActivitySession
- Activity
- CustomDimension
- PageviewData
- ScreenviewData
- EcommerceData
- ECommerceAction
- TransactionData
- ProductData
- EcommerceType
- GoalSetData
- GoalData
- EventData
- Try it!
Returns User Activity data.
HTTP request
POST https://analyticsreporting.googleapis.com/v4/userActivity:search
The URL uses gRPC Transcoding syntax.
Request body
The request body contains data with the following structure:
JSON representation | |
---|---|
{ "dateRange": { object( |
Fields | |
---|---|
dateRange |
Date range for which to retrieve the user activity. If a date range is not provided, the default date range is (startDate: current date - 7 days, endDate: current date - 1 day). |
viewId |
Required. The Analytics view ID from which to retrieve data. Every SearchUserActivityRequest must contain the |
user |
Required. Unique user Id to query for. Every SearchUserActivityRequest must contain this field. |
activityTypes[] |
Set of all activity types being requested. Only acvities matching these types will be returned in the response. If empty, all activies will be returned. |
pageSize |
Page size is for paging and specifies the maximum number of returned rows. Page size should be > 0. If the value is 0 or if the field isn't specified, the request returns the default of 1000 rows per page. |
pageToken |
A continuation token to get the next page of the results. Adding this to the request will return the rows after the pageToken. The pageToken should be the value returned in the nextPageToken parameter in the response to the SearchUserActivityRequest request. |
Response body
If successful, the response body contains data with the following structure:
The response from userActivity:get
call.
JSON representation | |
---|---|
{
"sessions": [
{
object( |
Fields | |
---|---|
sessions[] |
Each record represents a session (device details, duration, etc). |
totalRows |
Total rows returned by this query (across different pages). |
nextPageToken |
This token should be passed to SearchUserActivityRequest to retrieve the next page. |
sampleRate |
This field represents the sampling rate for the given request and is a number between 0.0 to 1.0. See developer guide for details. |
Authorization Scopes
Requires one of the following OAuth scopes:
https://www.googleapis.com/auth/analytics.readonly
https://www.googleapis.com/auth/analytics
User
Contains information to identify a particular user uniquely.
JSON representation | |
---|---|
{
"type": enum( |
Fields | |
---|---|
type |
Type of the user in the request. The field |
userId |
Unique Id of the user for which the data is being requested. |
UserIdType
Represents various types of user identification available.
Enums | |
---|---|
USER_ID_TYPE_UNSPECIFIED |
When the User Id Type is not specified, the default type used will be CLIENT_ID. |
USER_ID |
A single user, like a signed-in user account, that may interact with content across one or more devices and / or browser instances. |
CLIENT_ID |
Analytics assigned clientId. |
ActivityType
Enums | |
---|---|
ACTIVITY_TYPE_UNSPECIFIED |
ActivityType will never have this value in the response. Using this type in the request will result in an error. |
PAGEVIEW |
Used when the activity resulted out of a visitor viewing a page. |
SCREENVIEW |
Used when the activity resulted out of a visitor using an application on a mobile device. |
GOAL |
Used to denote that a goal type activity. |
ECOMMERCE |
An e-commerce transaction was performed by the visitor on the page. |
EVENT |
Used when the activity is an event. |
UserActivitySession
This represents a user session performed on a specific device at a certain time over a period of time.
JSON representation | |
---|---|
{
"sessionId": string,
"deviceCategory": string,
"platform": string,
"dataSource": string,
"activities": [
{
object( |
Fields | |
---|---|
sessionId |
Unique ID of the session. |
deviceCategory |
The type of device used: "mobile", "tablet" etc. |
platform |
Platform on which the activity happened: "android", "ios" etc. |
dataSource |
The data source of a hit. By default, hits sent from analytics.js are reported as "web" and hits sent from the mobile SDKs are reported as "app". These values can be overridden in the Measurement Protocol. |
activities[] |
Represents a detailed view into each of the activity in this session. |
sessionDate |
Date of this session in ISO-8601 format. |
Activity
An Activity represents data for an activity of a user. Note that an Activity is different from a hit. A hit might result in multiple Activity's. For example, if a hit includes a transaction and a goal completion, there will be two Activity protos for this hit, one for ECOMMERCE and one for GOAL. Conversely, multiple hits can also construct one Activity. In classic e-commerce, data for one transaction might be sent through multiple hits. These hits will be merged into one ECOMMERCE Activity.
JSON representation | |
---|---|
{ "activityTime": string, "source": string, "medium": string, "channelGrouping": string, "campaign": string, "keyword": string, "hostname": string, "landingPagePath": string, "activityType": enum( |
Fields | ||
---|---|---|
activityTime |
Timestamp of the activity. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: |
|
source |
The source of referrals. For manual campaign tracking, it is the value of the utm_source campaign tracking parameter. For AdWords autotagging, it is google. If you use neither, it is the domain of the source (e.g., document.referrer) referring the users. It may also contain a port address. If users arrived without a referrer, its value is (direct). |
|
medium |
The type of referrals. For manual campaign tracking, it is the value of the utm_medium campaign tracking parameter. For AdWords autotagging, it is cpc. If users came from a search engine detected by Google Analytics, it is organic. If the referrer is not a search engine, it is referral. If users came directly to the property and document.referrer is empty, its value is (none). |
|
channelGrouping |
The Channel Group associated with an end user's session for this View (defined by the View's Channel Groupings). |
|
campaign |
For manual campaign tracking, it is the value of the utm_campaign campaign tracking parameter. For AdWords autotagging, it is the name(s) of the online ad campaign(s) you use for the property. If you use neither, its value is (not set). |
|
keyword |
For manual campaign tracking, it is the value of the utm_term campaign tracking parameter. For AdWords traffic, it contains the best matching targeting criteria. For the display network, where multiple targeting criteria could have caused the ad to show up, it returns the best matching targeting criteria as selected by Ads. This could be display_keyword, site placement, boomuserlist, user_interest, age, or gender. Otherwise its value is (not set). |
|
hostname |
The hostname from which the tracking request was made. |
|
landingPagePath |
The first page in users' sessions, or the landing page. |
|
activityType |
Type of this activity. |
|
customDimension[] |
A list of all custom dimensions associated with this activity. |
|
Union field activity_details . Depending on the activity_type , exactly one of the following fields will be set. activity_details can be only one of the following: |
||
pageview |
This will be set if |
|
appview |
This will be set if |
|
ecommerce |
This will be set if |
|
goals |
This field contains a list of all the goals that were reached in this activity when |
|
event |
This field contains all the details pertaining to an event and will be set if |
CustomDimension
Custom dimension.
JSON representation | |
---|---|
{ "index": number, "value": string } |
Fields | |
---|---|
index |
Slot number of custom dimension. |
value |
Value of the custom dimension. Default value (i.e. empty string) indicates clearing sesion/visitor scope custom dimension value. |
PageviewData
Represents details collected when the visitor views a page.
JSON representation | |
---|---|
{ "pagePath": string, "pageTitle": string } |
Fields | |
---|---|
pagePath |
The URL of the page that the visitor viewed. |
pageTitle |
The title of the page that the visitor viewed. |
ScreenviewData
JSON representation | |
---|---|
{ "screenName": string, "mobileDeviceBranding": string, "mobileDeviceModel": string, "appName": string } |
Fields | |
---|---|
screenName |
The name of the screen. |
mobileDeviceBranding |
Mobile manufacturer or branded name. Eg: "Google", "Apple" etc. |
mobileDeviceModel |
Mobile device model. Eg: "Pixel", "iPhone" etc. |
appName |
The application name. |
EcommerceData
E-commerce details associated with the user activity.
JSON representation | |
---|---|
{ "actionType": enum( |
Fields | |
---|---|
actionType |
Action associated with this e-commerce action. |
transaction |
Transaction details of this e-commerce action. |
products[] |
Details of the products in this transaction. |
ecommerceType |
The type of this e-commerce activity. |
ECommerceAction
Set of all actions associated with an e-commerce action.
Enums | |
---|---|
UNKNOWN |
Action type is not known. |
CLICK |
Click through of product lists. |
DETAILS_VIEW |
Product detail views. |
ADD_TO_CART |
Add product(s) to cart. |
REMOVE_FROM_CART |
Remove product(s) from cart. |
CHECKOUT |
Check out. |
PAYMENT |
Completed purchase. |
REFUND |
Refund of purchase. |
CHECKOUT_OPTION |
Checkout options. |
TransactionData
Represents details collected when the visitor performs a transaction on the page.
JSON representation | |
---|---|
{ "transactionId": string, "transactionRevenue": number, "transactionTax": number, "transactionShipping": number } |
Fields | |
---|---|
transactionId |
The transaction ID, supplied by the e-commerce tracking method, for the purchase in the shopping cart. |
transactionRevenue |
The total sale revenue (excluding shipping and tax) of the transaction. |
transactionTax |
Total tax for the transaction. |
transactionShipping |
Total cost of shipping. |
ProductData
Details of the products in an e-commerce transaction.
JSON representation | |
---|---|
{ "productSku": string, "productName": string, "itemRevenue": number, "productQuantity": string } |
Fields | |
---|---|
productSku |
Unique code that represents the product. |
productName |
The product name, supplied by the e-commerce tracking application, for the purchased items. |
itemRevenue |
The total revenue from purchased product items. |
productQuantity |
Total number of this product units in the transaction. |
EcommerceType
This represents the type of e-commerce data that is being returned.
Enums | |
---|---|
ECOMMERCE_TYPE_UNSPECIFIED |
Used when the e-commerce activity type is unspecified. |
CLASSIC |
Used when activity has classic (non-enhanced) e-commerce information. |
ENHANCED |
Used when activity has enhanced e-commerce information. |
GoalSetData
Represents a set of goals that were reached in an activity.
JSON representation | |
---|---|
{
"goals": [
{
object( |
Fields | |
---|---|
goals[] |
All the goals that were reached in the current activity. |
GoalData
Represents all the details pertaining to a goal.
JSON representation | |
---|---|
{ "goalIndex": number, "goalCompletions": string, "goalValue": number, "goalCompletionLocation": string, "goalPreviousStep1": string, "goalPreviousStep2": string, "goalPreviousStep3": string, "goalName": string } |
Fields | |
---|---|
goalIndex |
This identifies the goal as configured for the profile. |
goalCompletions |
Total number of goal completions in this activity. |
goalValue |
Value in this goal. |
goalCompletionLocation |
URL of the page where this goal was completed. |
goalPreviousStep1 |
URL of the page one step prior to the goal completion. |
goalPreviousStep2 |
URL of the page two steps prior to the goal completion. |
goalPreviousStep3 |
URL of the page three steps prior to the goal completion. |
goalName |
Name of the goal. |
EventData
Represents all the details pertaining to an event.
JSON representation | |
---|---|
{ "eventCategory": string, "eventAction": string, "eventLabel": string, "eventValue": string, "eventCount": string } |
Fields | |
---|---|
eventCategory |
The object on the page that was interacted with. Eg: 'Video'. |
eventAction |
Type of interaction with the object. Eg: 'play'. |
eventLabel |
Label attached with the event. |
eventValue |
Numeric value associated with the event. |
eventCount |
Number of such events in this activity. |