Manage Newspaper Subscriptions with Google Apps Script: A Complete Solution
Running a newspaper agency? Managing subscribers, invoices, and payments can be time-consuming, but this Google Apps Script simplifies it all! This powerful script automates subscriber management, invoice creation, payment tracking, PDF generation, and reporting, all within Google Sheets. Whether you’re handling daily newspaper deliveries, weekly supplements, or special items like New Year Calendars, this script is your one-stop solution. Click the copy buttons below to easily paste the code into your Google Sheets Script Editor!
What Does This Script Do?
This script provides a comprehensive system for your newspaper agency, allowing you to:
- Manage Subscribers: Add or update subscriber details (contact number, name, address, subscription type) using a form or prompts.
- Create Invoices: Generate invoices for subscriptions or items (e.g., Daily, Weekly, New Year Calendar) with custom amounts, stored in a dedicated sheet.
- Track Payments: Record payments and update subscriber records with the last payment date.
- Export Invoices as PDFs: Save invoices as PDFs in Google Drive and email them to the agency’s email address.
- Check Subscriptions: View a subscriber’s details and subscription status by contact number.
- Generate Reports: Create a summary report of total invoiced amounts and payments.
- Backup Data: Save a copy of your spreadsheet to Google Drive for safekeeping.
Perfect for: Newspaper agencies, magazine publishers, or any subscription-based business looking to streamline operations!
The Script
Below are the main script and two HTML files for forms. Use the copy buttons to quickly copy each into your Google Sheets Script Editor.
Main Script
Copy the main script to manage subscribers, invoices, payments, and more:
Subscriber Form (SubscriberForm.html)
Copy the Subscriber Form HTML to create a user-friendly form for adding or updating subscribers:
Invoice Form (InvoiceForm.html)
Copy the Invoice Form HTML to create a form for generating invoices with multiple items:
How to Use the Script
Follow these steps to implement the script in your Google Sheets:
- Open Your Google Sheet: Create or open a Google Sheet for your newspaper agency.
- Access Apps Script:
- Click Extensions > Apps Script in the Google Sheets menu.
- This opens the Apps Script editor in a new tab.
- Paste the Script and HTML Files:
- Click the “Copy Main Script” button and paste into a new file named
Code.gs
. - Click the “Copy Subscriber Form” button and paste into a new HTML file named
SubscriberForm.html
. - Click the “Copy Invoice Form” button and paste into a new HTML file named
InvoiceForm.html
. - Save all files by clicking the save icon or File > Save all.
- Click the “Copy Main Script” button and paste into a new file named
- Update Folder ID:
- In the
backupSheet
function, replaceYOUR_FOLDER_ID
with the ID of a Google Drive folder where backups will be stored. (Find the folder ID in the folder’s URL:https://drive.google.com/drive/folders/[FOLDER_ID]
)
- In the
- Run the Script:
- Reload your Google Sheet to see the “Subscription Management” menu.
- The first time you run any function (e.g., “Add/Update Subscriber (Form)”), Google will prompt you to authorize the script. Review and grant permissions.
- Use the Menu Options:
- Add/Update Subscriber (Form): Opens a form to add or update a subscriber’s details (contact number, name, address, subscription type).
- Add/Update Subscriber (Prompt): Uses prompts to enter subscriber details.
- Create Invoice (Form): Opens a form to create an invoice with multiple items (e.g., “Daily:100,Weekly:60”).
- Create Invoice (Prompt): Uses prompts to create an invoice.
- Check Subscriptions: View a subscriber’s details by contact number.
- Record Payment: Log a payment for a subscriber’s subscription or item.
- Export Invoice PDF: Generate a PDF for a specific invoice and email it to the agency’s email.
- Generate All Pending Invoice PDFs: Create PDFs for all pending invoices and email them.
- Create Summary Report: Generate a summary of total invoiced amounts and payments.
- Backup Sheet: Save a backup of the spreadsheet to Google Drive.
- Review Results:
- Success messages confirm actions (e.g., “Subscriber added,” “Invoice created”).
- Error messages appear for issues like invalid contact numbers or missing data.
Example Scenarios
- Add a New Subscriber:
- Menu: Select “Add/Update Subscriber (Form)”.
- Input: Enter contact number (e.g.,
1234567890
), name (e.g., “John Doe”), address (e.g., “123 Main St”), and subscription type (e.g., “Daily”). - Result: Adds a new subscriber to the
Subscribers
sheet.
- Create an Invoice:
- Menu: Select “Create Invoice (Form)”.
- Input: Enter contact number (e.g.,
1234567890
), name (auto-filled if subscriber exists), date (e.g.,2025-08-07
), and items (e.g., “Daily:100,New Year Calendar:50”). - Result: Creates an invoice in the
Invoices
sheet and a dedicatedInvoice_INV001
sheet.
- Record a Payment:
- Menu: Select “Record Payment”.
- Input: Enter contact number (e.g.,
1234567890
), subscription type (e.g., “Daily”), amount (e.g.,100
), date (e.g.,2025-08-07
), and optional notes. - Result: Logs the payment in the
Payments
sheet and updates the subscriber’s last payment date.
- Export Invoice PDF:
- Menu: Select “Export Invoice PDF”.
- Input: Enter invoice ID (e.g.,
INV001
). - Result: Saves a PDF to the “AppleInvoiceFolder” in Google Drive and emails it to the agency’s email.
Tips and Notes
- Contact Numbers: Must be 10 digits (e.g.,
1234567890
) for validation. - Subscription Types: Use “Daily,” “Weekly,” “Monthly,” or “New Year Calendar” in forms, or any custom type in prompts.
- Forms vs. Prompts: Forms (e.g., “Add/Update Subscriber (Form)”) are more user-friendly with dropdowns and pre-filled fields; prompts are simpler but require manual input.
- PDF Emails: PDFs are emailed to the active user’s email. Add an email column to the
Subscribers
sheet for direct customer emails (requires script modification). - Folder ID: Replace
YOUR_FOLDER_ID
inbackupSheet
with a valid Google Drive folder ID to avoid errors. - Performance: Large subscriber lists or multiple invoices may take a few seconds to process.
- Error Handling: The script provides clear error messages for invalid inputs (e.g., wrong contact number, missing name).
Why Use This Script?
This script is a must-have for newspaper agencies or subscription-based businesses because it:
- Saves Time: Automates subscriber management, invoice creation, and payment tracking.
- Reduces Errors: Validates inputs like contact numbers and dates, with user-friendly forms.
- Streamlines Billing: Generates professional invoice PDFs and emails them to the agency.
- Tracks Finances: Provides a summary report of invoices and payments for easy accounting.
- Ensures Data Safety: Backs up your spreadsheet to Google Drive.
It’s perfect for small to medium-sized newspaper agencies looking to manage subscribers efficiently without complex software.
Customize It!
Want to enhance the script? Here are some ideas:
- Add Email Column: Modify the
Subscribers
sheet to include emails and updatesendDueReminders
to email subscribers directly. - Custom Invoice Templates: Add your agency’s logo or branding to the invoice sheets created by
createInvoiceSheet
. - Automated Reminders: Set up a time-driven trigger to run
sendDueReminders
daily for pending invoices. - Subscription Expiry Alerts: Add a function to check
Last Payment Date
and alert for expiring subscriptions.
Drop a comment below if you need help customizing this script!
Try It Out!
Ready to transform your newspaper agency’s workflow? Use the copy buttons above to add the script and HTML files to your Google Sheets, test it with a few subscribers, and see how it simplifies your operations. Have questions or run into issues? Leave a comment, and I’ll help you out. Happy automating!
Posted on August 7, 2025
No comments:
Post a Comment