# Example: Tag Inventory by Category ObservePoint categorizes every tag into categories. For this example, we will focus on two categories: **Social Media** and **Advertising**. This example reports which **Social Media** and **Advertising** tags are on the most pages. # Using IDs In this example, we want to filter the resuts to include only tags in the **Social Media** and **Advertising** categories, so we must pass ID numbers for these categories. We get the IDs from the tag categories API endpoint: ```javascript Response from GET https://api.observepoint.com/v3/tag-categories [ // ... more categories omitted for brevity { "id": 3, "category": "Advertising" }, // ... more categories omitted for brevity { "id": 11, "category": "Social Media" }, ... ] ``` We see from that API response that we want tag category IDs `3` and `11`, which we use in our Grid API request below. # Grid API Request This request will return a list of unique tags in the **Social Media** and **Advertising** categories, along with some aggregate statistics about each tag: * **Unique page count**: How many unique pages have each tag * **Average duration**: How long, on average, does each tag take to load on the page, in milliseconds * **Average size**: How large, on average, is each tag's request payload in bytes ```javascript POST to https://api.observepoint.com/v3/reports/grid/cookies { "columns": [ // Request 3 grouped columns, TAG, TAG_VENDOR, and TAG_CATEGORY, {"columnId": "TAG", "groupBy": true}, {"columnId": "TAG_VENDOR", "groupBy": true}, {"columnId": "TAG_CATEGORY", "groupBy": true}, // Aggregated columns: // Number of unique pages with this tag: { "aggregatedColumn": {"columnId": "FINAL_PAGE_URL"}, "aggregateFunction": "count_distinct" }, // Average time to load the tag, in milliseconds: { "aggregatedColumn": {"columnId": "TAG_DURATION"} "aggregateFunction": "avg", }, // Average tag size in bytes: { "aggregatedColumn": {"columnId": "TAG_SIZE"} "aggregateFunction": "avg", } ], "filters": { "conditionMatchMode": "all", "conditions": [ { "filteredColumn": {"columnId": "TAG_CATEGORY_ID"}, "operator": "integer_in", "args": [11, 3] // means "social media" or "advertising", from previous query }, // (optional) Filter to only show the most recent audit run. This ensures you don't count old pages that may no longer exist. { "filteredColumn": {"columnId": "IS_MOST_RECENT_RUN"}, "operator": "integer_in", "args": [1] // means "yes, the most recent audit run" } ] }, "sortBy": [ // sort by unique page count, most common tags on top {"columnIndex": 3, "sortDesc": true} ], "page": 0, "size": 10000 // get the top 10,000 most common tags (more than enough for this example, which will probably return <100 unique tags } ``` # Example Response JSON ```javascript Grid API Response JSON { "rows": [ [ ["Pinterest", 204], // tag name and ID ["Pinterest", 124], // tag vendor and ID ["Social Media", 11], // tag category and ID 3547, // unique page count 54, // average duration, in milliseconds 403, // average size, in bytes ], [ ["Google Ads Remarketing", 184], // tag name and ID ["Google", 3], // tag vendor and ID ["Advertising", 3], // tag category and ID 2623, // unique page count 658, // average duration, in milliseconds 359, // average size, in bytes ], [ ["Floodlight Counter", 15], // tag name and ID ["Google", 3], // tag vendor and ID ["Advertising", 3], // tag category and ID 1767, // unique page count 163, // average duration, in milliseconds 390, // average size, in bytes ], [ ["Facebook Conversion", 232], // tag name and ID ["Facebook", 54], // tag vendor and ID ["Social Media", 11], // tag category and ID 1293, // unique page count 139, // average duration, in milliseconds 477, // average size, in bytes ], [ ["Bing Ads Conversion", 1274], // tag name and ID ["Microsoft", 16], // tag vendor and ID ["Advertising", 3], // tag category and ID 1180, // unique page count 457, // average duration, in milliseconds 116, // average size, in bytes ], [ ["TikTok Analytics", 1000], // tag name and ID ["TikTok", 510], // tag vendor and ID ["Advertising", 3], // tag category and ID 1062, // unique page count 525, // average duration, in milliseconds 44, // average size, in bytes ], [ ["Google Ads Conversion Tracking", 16], // tag name and ID ["Google", 3], // tag vendor and ID ["Advertising", 3], // tag category and ID 329, // unique page count 112, // average duration, in milliseconds 742, // average size, in bytes ], [ ["Adobe Advertising", 251], // ["Adobe", 1], // tag vendor and ID ["Advertising", 3], // tag category and ID 54, // unique page count 248, // average duration, in milliseconds 78, // average size, in bytes ] ] } ```