Using HubSpot logic to create smarter Analytics segments

In addition to our Google Docs scraper tool (which checks a list of websites on the use of the ga.js code), we also talked at #GAUCBE about creating smarter segments in Google Analytics.

Bringing context to the data

To get more valuable insights from your data, you'll have to add context. This way we can bring more emotion and intent into our Analytics data.

Intent you say?

 

In Marketing Automation tools like HubSpot, you can build internal logic to segment leads in marketing persona's or add them into a customer lifecycle stage.

Using smart blocks in HubSpot, you have the power to transfer this internal logic into your Analytics data to have more context in your Analytics reports and detect patterns in your visitor data.

This step-by-step guide will show how you can use the built-in contextual blocks to enrich your Analytics data. 

Prerequisites:

  • HubSpot Pro account
  • Universal Analytics account
  • Google Tag Manager in place  

 

Step 1: Create a smart block within your HubSpot design template

We added this smart block in the header template to get the smart block loaded on every HubSpot page of the account.

hubspot_design_-_smart_block.jpg

 

Step 2: Configure your Smart Block

Choose the internal logic you want to use, based on which smarter segments you need in Google Analytics.

This feature detects the visitor and matches his account using an existing HubSpot cookie in the visitor's browser.

hubspot_design_-_smart_block3.jpg

 

Step 3: Add Smart Rules

Configure your HubSpot smart block and add the Datalayer-push code, basing the value on the Smart Rule.

<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'VisitorPersona': 'Persona1'
});
</script>

Check this blogpost from Simo Ahava about the push() method with GTM.

hubspot_design_-_smart_block2.jpg

Step 4: Create a Custom Dimension in Google Analytics

Remember the ID from the Custom Dimension you've created.

hubspot_design_-_smart_block4.jpg

 

Step 5: Create a new variable within GTM

In Google Tag Manager, you'll have to create a new "Data Layer Variable" that will read the previously created HubSpot Data Layer.

hubspot_design_-_smart_block6.jpg

 

Step 6: Create your GTM tag to fill the Custom Dimension in Google Analytics

Change your existing GTM Universal Analytics tag and match the Custom Dimension (remember the index number from step 4) with the previously created GTM variable.

hubspot_design_-_smart_block5.jpg

 

Step 7: Change the tag trigger

HubSpot smart blocks will add the data layer code below your existing GTM snippet.

Because of this fact, you'll have to change the tag trigger in order to have it wait until the DOM is ready.

hubspot_design_-_smart_block7.jpg

 

Step 8: Test and publish

Using the GTM Preview mode, you can test the existence of the HubSpot data Layer and whether GTM is capturing this value.

 

Remember: Data is nothing without Context

Every company has its own goals and processes. The marketing technology landscape is becoming more and more complex with new tools popping up every week. 

You'll get the most possible return from these tools if you combine data to get more context. 

 

 

Meer weten? Contacteer ons!