Email Events API - No Data Until Batch Complete

SOLVE
juandahveed
Member

Here's some initial framework to help you see what's happening here. We have a weekly email that goes out, it gives users a little game where they can select option A vs. option B.

 

When they choose an option, they get sent to a landing page on our website.

 

When they hit our landing page, we want to display a simple message that says, "You chose option A and so did 45% of the other users". You get the idea, we're just seeing what the person chose in the email, and comparing it to what other people also chose in the email.

 

Now for the technical stuff.....

 

The email is being sent to our Contact List and is being sent as a "Timezone Email", so rough estimate it takes around 3/4 hours to complete. The thing is, we need the API data in real time, so when the user clicks an option on the email, we can compare their click to other clicks on the same email and display it on the landing page.

 

I have been using the Email Events API because we are tracking clicks, and I'm able to filter it for a time period, as well as a campaign and campaignID.

 

Few things to note: the campaign is the campaign the email is attached to, the campaignID is actually the Hubspot Internal ID that cooresponds to this email's send batch.

 

The problem I'm currently having is that I'm not able to get any API results until the batch is finished running, which ruins the idea of getting real time data. 

 

Here's the route I'm hitting, please let me know how I can go about getting the data that I would like to receive.

 

The Route I'm Hitting:

https://api.hubapi.com/email/public/v1/events

 

The Params I'm passing:

hapikey -> our API key

limit -> the amount of results I expect to receive back

eventType -> click

startTimestamp -> 1 week ago value

campaign -> hex value of campaign the email is associated with ex. 8ecf3638-79d1-4d20-aba6-d3a1d16882a4

campaignId -> Internal Hubspot ID of the send email ex. 97084601

 

The Response I'm getting:

{
    "hasMore": false,
    "offset": "CgoY__________9_",
    "events": []
}
 
Here's some more follow up information.
 
If I remove the campaign and campaignId, and I just ask for a click type, I CAN see the click of the email that I myself received, even though it's part of the batch that is still running. As soon as I try to narrow down with the campaignId, the response doesn't return anything. I can also see in the Hubspot CRM the data for the email even though it's still running, so we know the data exists.
 
Is there another route I can hit instead that has real time data?
Is there a route where I can enter the emails ID instead, and get real time data?
I have yet to see a route where I can enter an email ID and get it's information, that would be super helpful.
0 Upvotes
1 Accepted solution

Accepted Solutions
Mike_Eastwood
Solution
Key Advisor | Gold Partner

Hi @juandahveed 

 

Can you store the data in your Landing Page rather than HubSpot?

 

Not sure what CMS you're using for your Landing Page... But, you could increment a value (from a GET Parameter) in your database everytime the page loads. Then display the data on your page.

 

Would that work?

Mike

View solution in original post

0 Upvotes
7 Replies 7
dennisedson
Community Manager

hey @juandahveed , Sorry for the delayed response!

@tjoyce , @Mike_Eastwood  what do you think of this?

Thanks,

Dennis


We are excited to announce that the Community will be launching a weekly newsletter on November 2, 2020!
Sign up today!
Mike_Eastwood
Solution
Key Advisor | Gold Partner

Hi @juandahveed 

 

Can you store the data in your Landing Page rather than HubSpot?

 

Not sure what CMS you're using for your Landing Page... But, you could increment a value (from a GET Parameter) in your database everytime the page loads. Then display the data on your page.

 

Would that work?

Mike

View solution in original post

0 Upvotes
juandahveed
Member

I like where you are going with this, it's a really unique idea. There's only 1 problem that I can think of. Since the email goes out every week, I'd need to cover for the event that someone clicks a link that's more then 1 week old. So if I could pass the name of the email as an argument, then I could save values in the database with reference to the particular email name. Currently, when you create a tracking link in Hubspot, I don't see that option. I'm stuck there.

0 Upvotes
juandahveed
Member

I'm still not thrilled that this was the solution, I feel like the API should accomodate for this, it doesn't seem like behavior that is out of the norm. The data is all there, it's odd to be that I couldn't easily get it. However; I love the solution and since we were using wordpress I can just save to the options table, and use it in a EAV database model to make it work. The data then becomes evergreen and it'll always be good, all that good stuff.

 

Thanks for the input and giving me the nudge to think about it in a different way.

0 Upvotes
tjoyce
Recognized Expert | Platinum Partner

Am I oversimplifying if I say why not create 2 events? Maybe the campaignid key is reserved and waits til the end of the campaign to retreive results.

 

The first event would not have the proper campaign and campaignid keys in it? 

Something like an underscore prefix

__campaign -> hex value of campaign the email is associated with ex. 8ecf3638-79d1-4d20-aba6-d3a1d16882a4

__campaignId -> Internal Hubspot ID of the send email ex. 97084601

 

and then the second event would be the real event?

campaign -> hex value of campaign the email is associated with ex. 8ecf3638-79d1-4d20-aba6-d3a1d16882a4

campaignId -> Internal Hubspot ID of the send email ex. 97084601

 

Just a thought, I have never used that particular API endpoint.

0 Upvotes
juandahveed
Member

I'm having a hard time following what you were trying to do here. If the batch is still running, then you can't access any API data on it. It would be nice if there was a route that was something like..... /emails/:uniqueEmailId that would pull all the data from an email, including the Events, where I could filter by click type.

0 Upvotes
juandahveed
Member

Just to explain the work flow, it works like this....

1) Hubspot emails an email to a user

2) User clicks a link on the email, it's either Option A or Option B

3) The user is sent to a page on my website, AND in the meantime, I'd like to use an endpoint to find out two things.... 

3 a) How many people have clicked these two links combined
3 b) How many people clicked option A or option B, it doesn't matter which

 

Then I can show the user a page on our website that says something like... "You chose Option A" which I can get from a $_GET parameter, AND I want to say, "35% of people chose option A" -- Because from the API, I would be able to do the simple math of, how many people clicked the links, verses what types of links they clicked....

 

 

Does that make sense?

0 Upvotes