Yes, you can do contextual targeting via key values in Google Ad Manager. The steps are straightforward.
a. You have to create new key and value pairs that depicts the context of the pages.
b. Set targeting for line items with the same key-values or create line items targeting those key-values.
b. Add the key-values to GAM ad requests to let Ad Manager know what the page is about (context of the page). So, whenever GAM detects the pages with your new key and value pairs, specific line items will be triggered for competition/delivery.
Example: Let’s assume you are running a sponsorship campaign with an auto advertiser who would like to target your “automobile” pages. You can add key-values to GPT on the relevant pages and set key-value targeting for the advertiser’s line items. Now, when an ad request from the pages reaches GAM, only the advertiser’s line item will be triggered for delivery. If it is from any other page, Google won’t trigger the line items.