I'm fetching all the "New Lead" (type 12) Activity records in a given interval. In that interval, I notice a fairly good number of Lead IDs which have multiple New Lead Activity records associated. The usual pattern is:
{"id":123,"leadId":8787,"activityDate":"2015-06-01T06:48:58Z","activityTypeId":12,"primaryAttributeValueId":8787,"primaryAttributeValue":"XYZ","attributes":[{"name":"Created Date","value":"2015-05-21"},{"name":"Source Type","value":"Web service API"}]}
{"id":123,"leadId":8787,"activityDate":"2015-06-01T06:54:28Z","activityTypeId":12,"primaryAttributeValueId":4242,"primaryAttributeValue":"Foo Bar","attributes":[{"name":"Created Date","value":"2015-06-01"},{"name":"Source Type","value":"Web service API"}]}
Why would I get multiple entries for the same Lead ID? Any way to avoid that (it basically wastes results I get back from the API, where all I want is to get all Leads created in a specific time interval)? If I can't avoid that, which one of those entries should I "favor"? The first one? The last one?
Thanks!
Hi Carlo
i'm interested in this issue.
I tried to happen this issue but I cannot.
Could you check this lead's all activity log via browser login?
This is what I see; notice the double New Lead activity; there are more activities following these, of course.
Event ID | Date/Time EDT | Activity Type |
586799275 | 2015-05-21 13:30:40 | Click Link |
586799309 | 2015-05-21 13:30:43 | Visit Web Page |
595864829 | 2015-06-01 02:48:28 | Visit Web Page |
595864846 | 2015-06-01 02:48:30 | Click Link |
595864869 | 2015-06-01 02:48:32 | Visit Web Page |
595864884 | 2015-06-01 02:48:33 | Click Link |
595864921 | 2015-06-01 02:48:38 | Visit Web Page |
595864938 | 2015-06-01 02:48:39 | Click Link |
595865059 | 2015-06-01 02:48:52 | Visit Web Page |
595865135 | 2015-06-01 02:48:57 | Visit Web Page |
595865073 | 2015-06-01 02:48:58 | New Lead |
595865074 | 2015-06-01 02:48:58 | Change Revenue Stage |
595868073 | 2015-06-01 02:54:28 | New Lead |
595872097 | 2015-06-01 03:01:47 | Click Link |
595872106 | 2015-06-01 03:01:47 | Visit Web Page |
595872109 | 2015-06-01 03:01:52 | Change Data Value |
595872110 | 2015-06-01 03:01:53 | Change Data Value |
595872111 | 2015-06-01 03:01:53 | Change Data Value |
596055227 | 2015-06-01 07:39:20 | Visit Web Page |
596123202 | 2015-06-01 09:06:59 | Visit Web Page |
Have you confirmed that there's no merge activity that happened? If you open up each of those New Lead activities to look at the activity detail, it should give you more useful information, including the ID of the leads at that moment, so you can see if there were two different leads. It could also have something to do with anonymous leads converging into one known record.
I honestly don't know; all I'm trying to do is to rely on the lead activity REST API to fetch details about Leads created in a specific time frame. And I was a bit surprised to see multiple "new lead" activities for the same Lead.
Looking at the details of the two "new lead" activities here, I see that the first one references the company name, and the LeadID mentioned in those details is the XYZ; the second one references the person's first and last names, and the LeadID is a different one. In the API calls, the returned leadId is the same for both events, but the "primaryAttributeValueId" matches the LeadID in the first event, and a different LeadID (consistent with what I see in UI) in the second one...
So, considering what my goal is, as stated above, what should I do?
1) ignore New Lead events which reference a LeadID already covered by a previous New Lead event
2) ignore leadID in the New Lead event payload, and rely on primaryAttributeValueId - which is different in both cases
3) overwrite previously seen New Lead events which reference the same LeadID covered by a subsequent New Lead event
?
What I can guess from further investigations is that a New Lead activity like this one:
{"requestId":"3cb4#14e2bbf9b1a","result":[{"id":123,"leadId":87,"activityDate":"2015-06-03T02:57:18Z","activityTypeId":12,"primaryAttributeValueId":4242,"attributes":[{"name":"Created Date","value":"2015-05-19"},{"name":"Source Type","value":"Web service API"}]},
...is really a merge activity, where 4242 is merged into 87.
As a matter of fact, I can see that 87 was created years ago, while 4242 cannot be found.
I suppose I just wonder why this is listed as a New Lead activity rather than a merge one...
Hey Carlo,
It depends on how you want to handle merged records. I would lean towards option 1 since this will reliably show the initial creation event for you records, regardless of whether they have been merged. However, option 2 will account for the creation events of leads which were merged into the master record, if this is needed for you. Option 3 I would not recommend since this will wholly overwrite your first creation event for a master record.