Skip to content
Help Center Contact support

Google Ad Manager: Send Hum Targeting Key Value Pairs with Ad Requests

On this page
  1. Enabling Hum Personalization on Your Website
  2. Prerequisites
  3. Instructions to Enable Hum Personalization

Enabling Hum Personalization on Your Website

This guide will help you understand how to enable Hum personalization on your website by integrating a JavaScript
snippet. This integration ensures that advertisements are personalized according to user preferences by accessing stored
data and targeting ads accordingly.

Prerequisites

  • Ensure you or your vendor have access to your website’s source code.
  • Basic knowledge of JavaScript and Google Tag Manager operations.
  • The capability to edit and deploy changes to your web pages.

Instructions to Enable Hum Personalization

Follow these steps to add the necessary JavaScript snippet to your site before Google Ads are rendered:

  1. Access Your Website’s Codebase:
    • Ensure you have the necessary permissions to modify your website’s HTML and
      JavaScript files.
    • Navigate to the portion of your website where Google Ads services are
      initialized (googleTag.enableServices() is called).
  2. Integrate the JavaScript Snippet:
    • Add the following JavaScript snippet before the call to
      googleTag.enableServices()
      
      var personalizationKey = "hum_" + clientShortName + "_ad_personalization";
      var keys = [personalizationKey];
      keys.forEach(x => {
         var item = localStorage[x];
         if (item) {
               var allTargets = JSON.parse(item);
               Object.keys(allTargets).forEach(k => { googletag.pubads().setTargeting(k, allTargets[k]); });
         }
      });
                          
  3. Verify Implementation:
    • After the snippet is added, ensure it executes before the ads are served on your
      pages.
    • You can use browser developer tools to inspect the localStorage and
      confirm that keys are set correctly.
    • Ensure the googletag.pubads().setTargeting() method is populating
      correctly with the personalized data.
    • Test on Multiple Browsers:
      • Test the implementation across different browsers to ensure consistent
        behavior of the personalized ads.
      • Pay special attention to browsers with strict privacy settings that might
        restrict localStorage access.
  4. Deploy Changes:
    • Once confirmed working in a development or test environment, deploy these changes to
      your live website.
    • Monitor the website and ad performance to ensure that ads are personalized as expected
      and there are no errors related to the new script.

Was this article helpful?

Feedback isn’t a support request. Contact support.