Solved

Analytics API filter with tags

  • 7 January 2023
  • 2 replies
  • 52 views

Badge +2

Hi,

I'm hoping to get some more info on what's possible with the new analytics reports.
After doing some experimenting, I'm a bit confused about how the tag filters work and what I need to do to get the data I'm after. I assumed it would be an AND or an OR operator on the tags, but it doesn't seem to be working that way.

We have a set of tags:
- Tag A (tag_a)
- Tag B (tag_b)
- Tag B (tag_c)
My end goal is to find out "how many B tickets also have C tags”
The catch is that I want to exclude anything tagged A Ticket, which usually also have B Ticket tagged on them as well.

My first attempt was to do a "new_segments_count" report with tag_ids set to the ID for the tags, but the results are strange.
If I do just the B ticket tag, I get 103.
If I do just the C tag, I get 20.
If I do both together, I get 104 - even though all of the C ones are also tagged B.

Similarly:
Filtering A Ticket gives me 50,
Doing B + A Ticket gives me 117.

Any idea what's going on here, what I'm missing, or what I should be doing instead?

Thanks

icon

Best answer by Support Engineering 7 January 2023, 02:28

View original

2 replies

Userlevel 1
Badge +5

API tag filters will count conversations that currently include any specified tags in the request.  This is essentially an OR operation.  Also, segments are different than conversations which may account for some confusion here:

 

https://help.front.com/t/x2hz4vd/conversation-segments

 

If you're using the API and you want a total count of all conversations presently with only those tags, the better option is the List tagged conversations endpoint:

 

https://dev.frontapp.com/reference/get_tags-tag-id-conversations

 

Using the conversation ids returned from that endpoint for each tag would allow you to programmatically determine the set of B and C and not A.

 

--Evan

 

Badge +2

Thanks for your response. You're right, I was confused with the difference between conversations/segments.

I was hoping to avoid scraping the entire list of conversations every time (after the first time running this, only the previous month is needed and the analytics let me specify a date range), but aside from taking a little longer, getting the conversations by tags and doing the stats on my side worked 100%.

Reply