APIs & Integrations

Erin_Giffin
Member

Using Get All Campaigns endpoint produces duplicate count

I am writing a console application to retrieve ALL of the campaigns (https://developers.hubspot.com/docs/methods/email/get_campaigns_by_id) and then lookup the counts for the email performance individually using the Get campaign details endpoint (https://developers.hubspot.com/docs/methods/email/get_campaign_data).

The problem I am seeing is that there are many duplicate entries for a campaign in the Get ALL response. I thought this might be due to starting and then stopping and restarting an email campaign or when changes occurred to the campaign. I attempted to aggregate the sum of the duplicates and this seemed to work when I set my limit to 200. When I upped that amount because I still wasn’t seeing campaigns back to January of this year to 500, I started seeing the counts as being exactly double what HubSpot is reporting online for those campaigns. When I tried setting my limit to anything higher than 500, I think I exceeded the max because it would only send 500, regardless of what I set as the limit (over 500).

My question is… how should I treat duplicate entries in the GET All Campaigns response? Can I assume that I can aggregate the counts on the details GET or not, and if not, is there another way to get the actual performance over all time for the campaign? Thank you.

0 Upvotes
3 Replies 3
Dadams
HubSpot Employee
HubSpot Employee

Using Get All Campaigns endpoint produces duplicate count

Hi @Erin_Giffin

Are you seeing duplicate id's or duplicate groupId‘s? Each id would refer to a separate internal send, but the groupId refers to a set of sends that are all related. As an example, if you use the Smart Send feature to send an email based on the contacts’ time zones, each different timezone would be a separate id, but all of the separate sends for each time zones would have the same groupId (you’d also see LocalTimeBatch as the appName for those campaigns).

0 Upvotes
Erin_Giffin
Member

Using Get All Campaigns endpoint produces duplicate count

Separate but related question… even after I retrieve all the campaigns from GET All Campaigns by iterating until results.hasMore = false, I am not seeing many of the email campaigns that are available through the web interface. I am not sure how these missing campaigns differ from the ones that I do receive, they seem to all be more recent ones, as in, I see the campaigns for January and February and 2016, but not the ones from March or April. Thoughts? Do I need to call the GET Recent Campaigns (https://developers.hubspot.com/docs/methods/email/get_campaigns) in addition to GET All?

0 Upvotes
Erin_Giffin
Member

Using Get All Campaigns endpoint produces duplicate count

Based on what you said, I added an additional grouping to the data I receive and made the assumption that the “final” campaign entry, the one where id == groupId, is the one I should use for the purposes of retrieving the campaign details. It seems to work as desired. Thank you for that insight. Now if only the documentation on the site explained this… :wink:

0 Upvotes