Solved

The most simple way to now how many time an event was fired

  • 24 June 2022
  • 3 replies
  • 264 views

I need to track how many time a certain  event has been fired. 

Is it possible to get the number via Apmplitude API?

The only way I came up with is executing https://amplitude.com/api/2/events/list

then searching for the event I am interested in and than getting it  "totals" number

Is there a more simple way to accomplish this?

 

icon

Best answer by Saish Redkar 24 June 2022, 17:24

View original

3 replies

Userlevel 7
Badge +10

Hey @iryna_chorna 

I see two other ways of doing this via API if that’s what your primary use case is.

Let me know if I have interpreted your use case correctly. Hope this helps.

@Saish Redkar , thank you! I was able to get the events number with segmentation API endpoint. 

But I’ve run into an issue:

the number of events (e.g. “series” field) is not updated when repeating API call after firing the event in the application. Is the response cached somehow? The number is updated in Amplitude UI almost immeditaly wherease API call returns old number of events. Here are more detailed steps:

  1. Execute request 
    https://amplitude.com/api/2/events/segmentation?e={ "event_type": "my_event_name"}&start=20220629&end=20220629&m=totals

    Response is as follows:

  2. {
    "data": {
    "series": [
    [
    264
    ]
    ],
    "seriesCollapsed": [
    [
    {
    "setId": "",
    "value": 264
    }
    ]
    ],
    "seriesLabels": [
    0
    ],
    "xValues": [
    "2022-06-29"
    ]
    },
    "timeComputed": 1656512876764,
    "wasCached": true,
    "cacheFreshness": "FRESH",
    "novaRuntime": 101,
    "novaRequestDuration": 184,
    "novaCost": 0,
    "throttleTime": 0,
    "minSampleRate": 1.0,
    "transformationIds": [],
    "backend": "novaV2",
    "realtimeDataMissing": false,
    "timedOutRealtimeData": false,
    "missedCacheAndNotComputed": false,
    "partialMergedAndNewUserInformation": false,
    "prunedResult": false,
    "hitChunkGroupByLimit": false,
    "subcluster": 6,
    "millisSinceComputed": 554841,
    "queryIds": [
    "lD3O7HB2Oy"
    ]
    }
    1. Go to the app, fire event (open a page)
    2. Repeat the request from step1. Here I expect “series” to have value 265, but it’s still 264

What could be a reason for that? Thank you in advance

Userlevel 7
Badge +10

This could be happening due to caching.

Reply