Skip to main content

How to use Audience Targeting on HCWP Web Part

I blogged previously about the Audience Targeting feature in SharePoint. It allows for targeting navigation links and news posts to select audiences. Today, I want to explain another cool way to use Audience Targeting – in this case, to display documents from a Document Library using HCWP Web Part.

Use Case

I have a document library on a site that contains company policies. Some policies apply to Sales employees, and some apply to Marketing employees. On the main page of a site, I want to display policies from that library, but I want the results (policies displayed) to vary depending on who is logged in. If a member of a Sales Team is logged in – I want them to see just Sales-related policies and of a member of a Marketing Team is logged in – they need to see just marketing-related policies.


We will use HCWP Web Part to display information on a page and use the document library where the policies are located as a source. Audience Targeting (once enabled), will allow us to display just the files that are targeted towards a certain audience.

What is the HCWP Web Part?

Highlighted Content Web Part (HCWP) allows you to display and roll up documents and other types of content from a site or certain sites based on some criteria. I covered it in great detail here, so if this is the first time you hear about it – please make sure to get familiar with it first via that other post.

How to use Audience Targeting on HCWP Web Part

Step 1: Enable Audience Targeting on a Document Library

In order for HCWP Audience Targeting to work, we first need to enable Audience Targeting on the source, which, in our case, is a Document Library.

  1. Navigate to the Document Library where the documents reside, click Gear Icon > Library settings
  2. Click on Audience targeting settingsHow to use Audience Targeting on HCWP Web Part
  3. Click the checkbox next to Enable audience targeting, then click OKHow to use Audience Targeting on HCWP Web Part
  4. You will now notice Audience column appear on a document library where you enabled that setting

Step 2: Assign an Audience for the files in the document library

Just as explained above, the library gets another metadata column called Audience. Now we need to assign the Audience for each of the files. There are a few ways to assign metadata (individual file, bulk edit, Quick Edit) – please reference this post for all the options.

How to use Audience Targeting on HCWP Web Part

In my case, I have a total of 8 policy documents. Three of them got assigned an Audience of Sales Members, and the remaining five got assigned an Audience of Marketing Team Members.

How to use Audience Targeting on HCWP Web Part

Step 3: Enable and configure Audience Targeting on HCWP Web Part

The last step is to enable Audience Targeting on HCWP Web Part.

  1. Navigate to the page where you want to add HCWP web part to, edit the page, then add the HCWP web partHow to use Audience Targeting on HCWP Web Part
  2. Click the pencil on the left-hand-side to access additional settings of the HCWP web part
  3. Next, we need to configure the HCWP Web Part. In the Source drop-down, choose A document library on this site as a drop-down choice. Under the Document Library, choose the specific name of the document library where documents reside (Policies in my case). At the bottom of the screen, switch Enable audience targeting toggle on.How to use Audience Targeting on HCWP Web Part
  4. Publish the page


The user who is part of both Sales and Marketing sees all 8 policies

The user who is part of just the Sales team sees 3 out of 8 policies


  1. Security Groups used for Audience can be AD groups, Office 365 Groups, or Mail-enabled security groups. Please reference this post for additional information on the security groups
  2. Audience is not the same as security. If you do not assign an Audience to a  file, it will not be hidden when you query it with an HCWP web part and will show up when the user visits the page (where HCWP is embedded). Audience just controls the display of the information.

You may also like

Why you need to set up Navigation Audience Targeting when sharing externally

April 20th, 2021

You may also like

4 places where you can enable Audience Targeting feature in SharePoint

March 4th, 2021

You may also like

How to set security on links in the Hub Navigation using Audience Targeting

September 24th, 2020

Need SharePoint Help?

Hourly consulting, training and configuration services are available

Learn More