If you are targeting dynamic content based on scheduled dates and times, you may have run into issues with expiring end dates. Once an end date expires, the content in that row is no longer eligible to serve. To help you stay on top of expiring content, you can set up an email alert by copying and pasting a script into your Google Sheets feed.
Add an email alert
- Download the script text.
- In your feed, navigate to Tools > Script editor.
- Select Blank Project.
- Name the project in the top left hand corner.
- Delete all of the text in the script window (i.e.
function myFunction() { }
). It's important that all of the text is deleted for the alert to work correctly. - Copy and paste the entire script from the downloaded file into the window.
- Save the project.
- Run the script by either clicking the play button or navigating to Run > alertFunction.
- Since this script sends emails, you will be required to authorize the script. Email alerts will be sent from your email address since you're authorizing the script.
- Once the script runs, a new tab is created in your feed, called Email Info. Do NOT change the name of this tab, or the script will break.
- In the Email Info tab, you'll see questions in column A (red cells). Follow the instructions for each question, entering your answer in column B (yellow cells).
If you are using scheduling in more than one feed and want to set up alerts for all feeds, comma-separate your answers in Column B (e.g. Sheet 1, Sheet 2). Make sure to keep the order of the answers consistent for each question.
- Run the script again. You will notice that the cells in Column B turn green if you set up the alert correctly. If there are any errors, a dialog box will indicate what error has occurred. You should also receive an email if there are any rows in the feed expiring within 24 hours.
- The final step is to set the trigger, which tells the script to run automatically once a day. In the script, navigate to Resources > Current project’s triggers.
- Click the No triggers set up. Click here to add one now. link.
- In the Run dropdown, select alertFunction.
- In the Events dropdowns, select Time-driven, then Day timer, and then select the one-hour timeframe in which you want the alert to run. This means that the script will run once a day during the timeframe you selected.
- You can also click on the notifications link beneath the Time-driven dropdown to set up alerts for script failures.
- Click Save.
You're all set! You should begin receiving email alerts in the next scheduled timeframe.
Unsubscribe from alerts
To stop sending email alerts to specific email addresses, remove those email addresses from cell B9 of the Email Info tab of your feed. The next time the script is scheduled to run, this change will be effective.
To stop sending email alerts for a specific feed, remove that feed name and the corresponding answers for that feed from column B. This change will take effect the next time the script is scheduled to run.
To completely stop sending ALL email alerts, enter "yes" in response to the final question on the Email Info tab. The next time the script is scheduled to run, cell B15 will turn red.