Google Ad Manager: Send Hum Targeting Key Value Pairs with Ad Requests
2 min readUpdated Nov 11, 2024
On this page
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:
- 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).
- Ensure you have the necessary permissions to modify your website’s HTML and
- 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]); }); } });
- Add the following JavaScript snippet before the call to
- 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
localStorageand
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
restrictlocalStorageaccess.
- Test the implementation across different browsers to ensure consistent
- After the snippet is added, ensure it executes before the ads are served on your
- 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.
- Once confirmed working in a development or test environment, deploy these changes to
Was this article helpful?
Feedback isn’t a support request. Contact support.