Dayparting: The practice of limiting your advertising campaigns to the certain times of day where you make the big bucks.
This script isn’t too complicated, and it’s not too pretty, but it’s something a few people could probably use.
Features
- Pause and resume ads/campaigns at the times of your choosing
- All done automatically through the magic of “cron”
- Works with Facebook, MySpace, and AdBrite.
Requirements
- PHP5 with curl compiled in (your webhost probably has this)
- The ability to schedule periodic taks (your webhost probably lets you set cron jobs)
- Beer (because it’s always a good decision)
Tutorial
1. Download the zip file, and unzip it to a not web facing directory on your hosting service. (This has no web interface, so exposing it to the world would be silly.)
2. Edit config.php and put in your login credentials for the ad networks you want to use, and set the COOKIE_FILE, and LOG_FILE definitions. Those should be absolute paths. Something like “/home/my_user_name/daypart/var/log.txt”.
3. Get the ad id numbers for the campaigns you’d like to daypart.
- Facebook: Use the latest version of my Greasemonkey script to get the campaign/ad id’s. If you use a campaign id, the whole campaign will be paused, just like in the Facebook Ads interface.
- MySpace: Open the campaign info for the campaign you want to control. The url will contain the campaign’s id “campaign.html?campaignId=XXXXXX”.
- AdBrite: Open the campaign’s info, the url will contain the id: “manage_single_campaign.php?banner_id=XXXXXXXX”
4. Edit actions.php and set the start/stop times for each of your ads. All times are in 24H format. The timezone is whatever your server is set to.
// Example actions.php file
// Sham Wow on Facebook: pause at 4pm, resume at 4am
add_pause_resume("FB", "696969", 16, 4);
// Snuggie on MySpace: pause 12am (start of day), resume 8am
add_pause_resume("MS", "424242", 0, 8);
// Berries on AdBrite: pause at 11pm, resume at noon
add_pause_resume("MS", "232323", 23, 12);
5. Set up a cron job to execute the job.php file once an hour. Your hosting service probably has a neat web interface for doing this. Otherwise add an entry yourself (you’ll need to enter the actual path to your php5 executable, which will vary from place to place):
# Example crontab entry
15 * * * * /usr/local/php5/bin/php /home/my_user_name/daypart/job.php
6. Sit back and wait for the money to come in.
Conclusion
If you have any comments/problems/feature suggestions, leave a comment here, and I’ll respond if I feel like it. Or you can email me at nathanielstory (at) gmail.com
11 comments ↓
Hi mate, love your scripts, very clever… Just checking if there is a way I can test the cron jobs are working?
The absolute path I used for the cron was:-
/usr/bin/php/home/*****/public_html/****/daypart/job.php
Does this seem right for Hostgator?
P.S. In the actions.php you accidentally have MS instead of AB, but I know what you meant. I drink too. lol
[...] Facebook Dayparting Script - From the same guy that did the above greasemonkey script comes the dayparting script. Dayparting just simply means you only run your ads during certain parts of the day. Rather than doing this manually, this script will change the ads status for you. It is a bit difficult to configure and you need your own hosting plan, but it is well worth it once you realize how much money it can keep you from wasting on ads that don’t perform well during certain times of day. As an added bonus, this also works with Adbrite and Myspace. [...]
Killer scripts. Thanks Nathan.
[...] off my butt and see if there were any scripts around that might help. I was lucky enough to find this script and this script at [...]
Thanks for the script, but…Is there supposed to be something in the var folder? I keep getting an error related to getting something out of this folder but the download that I have has nothing in this folder.
Just saw this, no more manual dayparting for me!
Thanks homey
I assume I can add as many add_pause_resume commands as I want for each campaign?
example:
add_pause_resume(”MS”, “424242″, 0, 5);
add_pause_resume(”MS”, “424242″, 10, 12);
add_pause_resume(”MS”, “424242″, 13, 17);
thanks!
Will the dayparting script be updated to work with Facebook’s new interface?
Thanks….
Getting this error. Any idea why? Thanks!
Notice: Trying to get property of non-object in /home/xxxxx/xxxxx/lib/fbrobot.php on line 54
Notice: Trying to get property of non-object in /home/xxxxx/xxxxx/lib/fbrobot.php on line 55
By the way…that error is emailed from the cron job. Seems like the cron job is running the script but something’s broken
Hello,
Does this script still work? I can’t seem to get it working ever after following all the instructions. Is there another version? Thanks!
Leave a Comment