Expand my Community achievements bar.

Adobe Anaytics API Date Range last 1h, last 24h, etc

Avatar

Level 1

 

Hi there,

 

Please post your question in the following community: https://adobe.ly/3NI8n1q

Experts here will be able to assist you better. Thanks


^BS

-----------------------------question------------------

Hi,

 

I am trying to figure out if there would there be a way to specify (say) last 24h in the dateRange for an Adobe Analytics API call, instead of concrete dates such as:"2024-10-13T00:00:00.000/2024-10-14T00:00:00.000" in the following JSON below {
            "type": "dateRange",
            "dateRange": "2024-10-13T00:00:00.000/2024-10-14T00:00:00.000",
            "dateRangeId": "thisMonth"
        }

 

Does anybody know if that is posible and the syntax of a sample JSON. I am sucessfully

calling this:  https://appservice-reporting5-1.omniture.com/reporting/1.0/analytics/users/reports/ranked?locale=en_... with the JSON:

{
"rsid": "schopreprodmain",
"globalFilters": [
{
"type": "dateRange",
"dateRange": "2024-10-13T00:00:00.000/2024-10-14T00:00:00.000",
"dateRangeId": "thisMonth"
}
],
"metricContainer": {
"metrics": [
{
"columnId": "metrics/visits:::0",
"id": "metrics/visits",
"filters": [
"STATIC_ROW_COMPONENT_1"
]
},
{
"columnId": "metrics/visitors:::2",
"id": "metrics/visitors",
"filters": [
"STATIC_ROW_COMPONENT_3"
]
},
{
"columnId": "metrics/visits:::4",
"id": "metrics/visits",
"filters": [
"STATIC_ROW_COMPONENT_5"
]
},
{
"columnId": "metrics/visitors:::6",
"id": "metrics/visitors",
"filters": [
"STATIC_ROW_COMPONENT_7"
]
}
],
"metricFilters": [
{
"id": "STATIC_ROW_COMPONENT_1",
"type": "segment",
"segmentId": "xxxx"
},
{
"id": "STATIC_ROW_COMPONENT_3",
"type": "segment",
"segmentId": "xxxx"
},
{
"id": "STATIC_ROW_COMPONENT_5",
"type": "segment",
"segmentId": "xxxx"
},
{
"id": "STATIC_ROW_COMPONENT_7",
"type": "segment",
"segmentId": "xxxx"
}
]
},
"settings": {
"countRepeatInstances": true,
"includeAnnotations": true
},
"statistics": {
"functions": [
"col-max",
"col-min"
]
},
"capacityMetadata": {
"associations": [
{
"name": "applicationName",
"value": "Analysis Workspace UI"
}
]
}
}
5 Replies

Avatar

Employee Advisor

I don't think there we have preset the last 24 hours in Analytics. The only is to use a static date range or build a rolling last 24-hour custom date range and use the same in API.

Avatar

Level 1
Hi Jennifer,
 
Thank you for the response. 
 
Yes, I can surely parameterize. 
 
But I was hoping for a shortcut, like -1h, -2h, -1d, etc., like some other systems allow, which is not possible here.
 
Thank you, Boris

Avatar

Community Advisor and Adobe Champion

Yes, sadly there is no pre-defined ranges at those granularities.

Avatar

Community Advisor and Adobe Champion

How are you running your API Calls?

 

If you parameterize the Date Fields in your cron or DB job, etc, you should be able to pass the expected "last 24 hours" or "last hour" (though this one I would be careful with as post processing likely hasn't finished yet... even the last 24 hours, I would be tempted to use a 24 hour period, but offset by an hour to ensure post processing)

 

However, in your Date Range:

"dateRange": "2024-10-13T00:00:00.000/2024-10-14T00:00:00.000",

 

if parameterized, you should be able to pass something like:

"dateRange": "2024-10-27T11:00:00.000/2024-10-28T12:00:00.000"

Avatar

Community Advisor and Adobe Champion

I accidentally gave you 25 hours, but you should get the idea.

 

While the Swagger side doesn't let you access that directly, I can see it in my debug mode in Workspace when I adjust the time in my date range:

Jennifer_Dungan_0-1730131591015.png

 

Jennifer_Dungan_1-1730131624738.png

 

Jennifer_Dungan_2-1730131644464.png