How to compute Unified Data with Priority RulesUpdated 25/06/2020


The code below can be copied directly into a (User) Processor in Hull and configured via variables to unify attributes based on various input attributes. The input attributes are considered in the order defined and the first matching input attribute will determine the value of the unified attribute. The code is also able to handle the unification of top-level attributes such as first_name and last_name to properly display that information in user profiles in Hull.

Example Scenarios

Fallback - Priority

Unified last_name (top-level attribute)

Assuming you have various systems such as Salesforce and Hubspot connected to Hull, incoming data is stored as grouped attributes, so you most likely have the following attributes on a user profile:

  • salesforce_lead.last_name
  • salesforce_contact.last_name
  • hubspot.last_name

Now your team decides to pick up that the information and prioritize the data. You might end up defining that information about a customer which is represented as a Salesforce Contact has probably the most accurate data since it has been vetted, so salesforce_contact.last_name takes top priority. If that data is not present, your team may decide that leads vetted by a sales person are still more accurate than marketing data from Hubspot, so you define that salesforce_lead.last_name takes precedence over hubspot.last_name.

Now all you have to do is to create a new variable in the Settings tab of the Processor under Custom Variables to indicate that you want to apply a fallback strategy for the top-level attribute last_name. So you enter the key fallbacks__last_name and a value of salesforce_contact.last_name;salesforce_lead.last_name;hubspot.last_name;. That's it, now the Processor will execute the logic to unify the top-level attribute last_name for you.

Unified job_title

Assuming you have various systems such as Salesforce and Hubspot connected to Hull, incoming data is stored as grouped attributes, so you most likely have attributes similar to the following on a user profile:

  • salesforce_lead.title
  • salesforce_contact.title
  • hubspot.job_title

Now your team decides to pick up that the information and prioritize the data. You might end up defining that information about a customer which is represented as a Salesforce Contact has probably the most accurate data since it has been vetted, so salesforce_contact.title takes top priority. If that data is not present, your team may decide that enriched marketing data in Hubspot is still more accurate than Sales data from leads, so you define that hubspot.job_title takes precedence over salesforce_lead.title.

Now all you have to do is to create a new variable in the Settings tab of the Processor under Custom Variables to indicate that you want to apply a fallback strategy for the unified attribute job_title. So you enter the key unified__job_title and a value of salesforce_contact.title;hubspot.job_title;salesforce_lead.title. That's it, now the Processor will execute the logic to unify the attribute job_title and store the output in a group called unified. To consolidate your systems, you should use in the outgoing data section of all connectors the attribute unified/job_title instead of a cross-reference mapping from a particular other source.

Configuration

Configuration is entirely done via variables in the Settings of the Processor. The keys of the variables define the type of unification:

  • keys following the convention fallbacks__<ATTRIBUTE_NAME> define top-level attribute unification; naturally there are only two values allowed for <ATTRIBUTE_NAME> which are first_name and last_name. It is not recommended to unify the email with that code even you can do it.
  • keys following the convention unified__<ATTRIBUTE_NAME> define grouped attribute unification; you can define any name that makes, but it is recommended to use a snake_cased attribute name.

The value for each variable takes an ordered list devided by semicolons. The code will parse that list and apply the first matching attribute value as the value for the unified attribute

Remarks

If you want to prioritize input attributes based on the most recent update you might want to check out the guide for last-change based updates here

You can also combine them into one Processor, to do so, copy all the function in the UTILITY FUNCTIONS block except splitVariableToList from this Gist into the corresponding block of the last changes code. Then add everything from the YOUR LOGIC block into the corresponding block of the last changes code.

The naming conventions for the variables are designed in a way they won't clash, so you can use both strategies for unification in one Processor.

Embedded content: https://gist.github.com/SMK1085/11b5a43a7e7363477351706add5bc932