Facebook Day Parting Script

Status
Not open for further replies.

goddfadda

Pasta Eatin Mofo
Dec 1, 2007
423
11
0
I tend to like my ads running during peak times for the time zone that it is in. Facebook tends to be annoying and not offer day-parting yet. During off-peak hours, CTR tends to take a big shit and sometimes conversions.

I wrote this on Applescript for mac. Sorry pc peeps. I have a home-built pc too but only to test lp's on IE 7 and now with VMWare I dont even use it for that. Honestly I'm a linux/unix guy, and having unix under OS X just pwns.

Anyway I wanted this to work with safari, which has a built-in javascript scriptable layer. (You can externally control javascript on any web page via another scripting language such as applescript or unix scripts).

This is a very crude implementation, but it gets the job done. As many of you know, sometimes its just easier to set a bid to .01 instead of 'pausing' and ad. This script assumes you'd set the bid to say .16 when you want to enable, and to .01 when you want to disable an ad. Obviously you can set it to whatever you want.


1. This assumes you are logged into facebook. Facebook doesn't have to physically be open, but you must have a cookie saved. This script will not log in for you (but it will open ad manager & your ad for you).
2. This assumes your ad is set to 'running'. If you have it set to 'paused' the script will still work (great for testing!) but obviously your ad won't run because it is still paused. The script doens't unpause for you. Setting the bid to .01 is effectively pausing unless you have a 1% ctr.
3. I'm not responsible for anything u fuck up


First - choose your ad that you want to automate. View that ad in your browser. The ad url will be something like this:
hxxp:/ /www.douchebook.com/ads/manage/?act=53834323&ag=7332209182511

See the act=53834323 and ag=7332209182511

You will need these numbers. This is how the script tells the page to update the bid using facebook's ajax that seems to break every other day (but thats another story...).

Since this is crude, I keep two scripts. Bid On and Bid Off. Basically you put all the bid increases in the Bid On versions and the descreases in the Bid Off version.

Here's the script. Paste it in a new doc in /Applications/AppleScript/Script Editor.app:
Code:
-- Facebook ad bid automator
-- by goddfadda
-- Oct 21, 2008
-- i'm not responsible for your stolen commissions by my leet-ness

set act to "999999999" -- set this to the act variable in your desired ad
set ag to "9999999999999" -- set this to the ag variable in your desired ad
set bid to ".01" -- set this to the desired bid (duh)

tell application "Safari"
    activate
    tell (make new document) to set URL to "http://www.facebook.com/ads/manage/?act=" & act & "&ag=" & ag
    delay 2 -- if you are on a ghetto fab 56k, increase the delay
    
    set doc to document 1
    log (doc's name)
    
    do JavaScript "document.getElementById('bid').value = '" & bid & "'" in doc
    do JavaScript "admanager_set_adgroup_bid(" & act & "," & ag & ");" in doc
    
end tell

as the script specifies, set the act value in quotes to the act value of your ad's url above. ditto for the ag variable. Set the bid to whatever you want in the quotes. (DONT FORGET TO PUT A DECIMAL .16 not $16) !!!!!

Now you can run the script. It will open safari, open your ad, wait 2 seconds, set the bid to whatever you specified, then call the update script. You'll see the little facebook updating bar thingie.

That's it. Bid On. If you want to do this with multiple ads, just copy the script several times in the same document. But change the variables accordingly for each instance.

Now when you run it, it will systematically go through all your ads and update them.

My recommendation is dupe the script when you are done, and have the dupe set all the bids to .01 (off). Now you have a bid set script and a bid off script. You can schedule them to run via iCal or cron.

Here's how to do that with ical.
OSXFAQ • View topic - iCal - Launch a Command Periodically
 


I wonder if you can accomplish the same thing using a firefox plugin like imacro.

Also, does adjusting the bid to .01 cent screw up the ad in any way or does is immediately recover when you reset it to the normal bid?
 
Thanks guys!

I wonder if you can accomplish the same thing using a firefox plugin like imacro.

Also, does adjusting the bid to .01 cent screw up the ad in any way or does is immediately recover when you reset it to the normal bid?

I have been doing it since I started back in March and it has never been a problem. Speed of recovery / disable seems to be the same as pausing if not faster. (about 5 - 10 mins, with the occasional stray click for 15 mins) The ad just gets right back into the groove.
 
Do you think they would know you're automating things? I know they mention that somewhere in the TOS. I was thinking of creating an automated ad submitter, not sure how smart they are as far as detecting something like that. I figure as long as you're not stupid with it (ie creating 10k ads), you should be fine, what do you guys think?
 
Do you think they would know you're automating things? I know they mention that somewhere in the TOS. I was thinking of creating an automated ad submitter, not sure how smart they are as far as detecting something like that. I figure as long as you're not stupid with it (ie creating 10k ads), you should be fine, what do you guys think?

i wouldnt worry about a script like this
 
Status
Not open for further replies.