Marketing Collaterals Library Index
View Sheet
Connecting to sheet…
Category Item Tags
📋
Google Apps Script Backend Setup
Connect your Google Sheet so the library pulls data automatically on load.
1
Open your Google Sheet (the one you want to use as the backend). Go to Extensions → Apps Script.
2
Create two sheets named Demand and Supply. Each needs columns: CATEGORY, ITEM, LINK, TAGS (comma-separated), and optionally MENU_GROUP to explicitly assign an entry to a menu section.
3
Paste the Apps Script code below into the editor. Replace YOUR_SHEET_ID with your actual Google Sheet ID (from the URL).
4
Click Deploy → New Deployment → Web app. Set "Execute as: Me" and "Who has access: Anyone". Copy the deployment URL.
5
In this HTML file, find APPS_SCRIPT_URL near the top of the script section and replace it with your deployment URL. The tool will then fetch live data on load.
Apps Script Code (paste into your project)
// ─── Media.net Marketing Collaterals Library — Apps Script ───────
// Paste this into Extensions → Apps Script in your Google Sheet.
// Sheet must have two tabs named exactly: "Demand" and "Supply"
// Columns: A=Category  B=Item  C=Link  D=Tags (comma-separated)  E=MENU_GROUP (optional)
//
// MENU_GROUP (Column E) lets you explicitly assign any row to a
// specific menu section in the dashboard. Accepted values:
//   Verticals
//   Products & Solutions (Demand)
//   Products & Solutions (Supply)
//   Partnerships
//   Case Studies
//   Integration Guides
//   RFIs & Pitches
//   Other Tags
//
// Leave column E blank to use automatic category-based routing.

function doGet(e) {
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const tab = e.parameter.tab || 'Demand';
  const ws = ss.getSheetByName(tab);
  if (!ws) return json({ error: 'Tab not found: ' + tab });

  const rows = ws.getDataRange().getValues();
  // Skip header row (row 1), skip rows with no Item value
  const data = rows.slice(1).filter(r => r[1]).map(r => ({
    category:  String(r[0] || '').trim(),
    item:      String(r[1] || '').trim(),
    link:      String(r[2] || '').trim(),
    tags:      r[3] ? String(r[3]).split(',').map(t => t.trim()).filter(Boolean) : [],
    menuGroup: r[4] ? String(r[4]).trim() : ''   // optional explicit menu section
  }));

  return json({ data });
}

function json(obj) {
  return ContentService
    .createTextOutput(JSON.stringify(obj))
    .setMimeType(ContentService.MimeType.JSON);
}