Legacy: How to Use the Reveal API to send data to Google Analytics (GA4)

Last Updated: December 21, 2023

🔍 Please note: this article is for customers on Standard Bundle, Enrichment, or Clearbit Platform plans.

Clearbit’s Reveal API allows you to de-anonymize your website traffic. To send data over to GA4, we’ll need to first push this data to Google Tag Manager’s data layer. Once the data is in Google Tag Manager, we can configure the tags and triggers that will map over to the corresponding GA4 custom dimensions.

1) Add the Reveal API client-side endpoint script(s) to Google Tag Manager

In Google Tag Manager create a custom HTML tag and add the following code:

<script> 
function revealCallback(response) {
var reveal = response;
window.reveal = reveal;
dataLayer.push({
event: "Clearbit Loaded",
reveal: reveal
});
};
</script>
<script src="https://reveal.clearbit.com/v1/companies/reveal?authorization=pk_XXXX&callback=revealCallback"></script>

Make sure to replace the pk_xxxx found in the last line with your own Clearbit account’s publishable key. We suggest you name the tag “Clearbit - Reveal API” but you can name it at your convenience. 

reveal-api-custom-html-tag.png

2) Create data layer variables in Google Tag Manager

Create data layer variables that will store the company attributes in sending over to GA4.

Two popular and useful company attributes are “Company Name” and “Company Domain”. 

Head over to the variables section and click new under the user-defined variables subsection. It’s important that the Data Layer Variable Name matches the value that will be returned by our Reveal API.

In the “Company Name” attribute’s case, that value is reveal.company.name. You can find the full list of attributes available here.

Clearbit Attribute Data Layer Variable Name
Company Name reveal.company.name
Company Domain reveal.company.domain
Company Sub Industry reveal.company.category.subIndustry
Company City reveal.company.geo.city
Company State reveal.company.geo.state
Company Country reveal.company.geo.country
Company Employees Range reveal.company.metrics.employeesRange
Company Estimated Annual Revenue reveal.company.metrics.estimatedAnnualRevenue

If the event that an IP address cannot be matched to a company, we can provide a default value within GA4. 

To do that “Set Default Value” checkbox and set it equal to “(Non-Company)” and “Convert false to” option and set it equal to “(Non-Company)” as shown below.

data-layer-variable-1.png

data-layer-variable-2.png

3) Create two Google Tag Manager tags for GA4

Google Tag Manager has two built-in tags that connect directly to Google Analytics 4: “Google Analytics: GA4 Configuration” and “Google Analytics: GA4 Event”.

A. Google Analytics: GA4 Configuration

The Google Analytics: GA4 Configuration tag’s loads Google Analytics onto your page. If you’ve been sending data to GA4 already, it’s possible this tag is already set up. 

If not, head over to the tags section, click new, and select “Google Analytics: GA4 Configuration” under the tag type list. You can follow Google’s help article to fetch your GA4 account’s Measurement ID https://support.google.com/analytics/answer/9539598?hl=en.

Check off the “Send a page view event when this configuration loads” and set its trigger to fire on All Pages.

ga4-config-tag.png

B. Google Analytics: GA4 Event

GA4 Event tag is used to send reveal data to GA4.

Create a new tag and select “Google Analytics: GA4 Event” under the tag type list. Select the previous tag from the “Configuration Tag” dropdown. Select the tag we created in the previous step. Then we need to set up the “User Properties”. 

Under the “Event Name” input box, type in “Clearbit Loaded”. (Specifying an event name helps you both understand when a specific interaction occurred on your website.)

The “Clearbit Loaded” event tells us the exact moment Clearbit’s reveal data was sent from Google Tag Manager over to Google Analytics. 

ga4-event-tag.png

C. Google Analytics: GA4 Event - User Properties

Within the “User Properties” section within the tag, map the 2 data layer variables we created to the GA4  to set those values. If these user properties have not been created in GA4 yet, we recommend using a PascalCase naming convention where the words are written together without any spaces and their first letter is capitalized.

Property Name Value
ClearbitCompanyName {{Clearbit - Company Name}}
ClearbitCompanyDomain {{Clearbit - Company Domain}}

 

ga4-event-tag-user-properties.png

D. Google Analytics: GA4 Event - Event Name

The last step in configuring is the “Google Analytics: GA4 Event” tag trigger. We want to fire this tag when the “Clearbit Loaded” event from our “Clearbit - Reveal API” tag fires. Click into it and create a new trigger called “Clearbit Loaded”. The trigger type should be set to Custom Event and the event name should be exactly “Clearbit Loaded”.

clearbit-loaded-trigger.png

The final “Google Analytics: GA4 Event” tag should look like this:

ga4-event-tag-complete.png

That's everything on Goggle Tag Manager. Make sure to publish your container changes before moving over to Google Analytics 4.

4)Create custom dimensions in Google Analytics 4

To send Clearbit’s reveal data to Google Tag Manager, we need to set up the corresponding custom dimensions in GA4 that will receive that data.

From within Google Analytics 4, head on over to the Admin section where you’ll find the custom definitions subsection within the property column.

ga4-admin.png

We’ll create 2 custom dimensions that match the user properties we set in our “Google Analytics: GA4 Event” tag. With “Company Name” as our example, click the create custom dimension button and fill in the following information: 

Dimension Name ClearbitCompanyName
Scope User
Description Clearbit Company Name
Event Parameter ClearbitCompanyName

Follow the same pattern for “Company Domain” and any other dimensions you’d like to create in the future.

ga4-custom-dimensions.png

Once this is set, you should now be able to see the data flow in GA4.Â