Adsense in PureBasic-Apps

Share your advanced PureBasic knowledge/code with the community.
jamirokwai
Enthusiast
Enthusiast
Posts: 798
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Adsense in PureBasic-Apps

Post by jamirokwai »

Hi there,

lately, I made one of my Apps free (SpeakToMe,http://the-crying-eye.com/SpeakToMe), and added Advertising using AdSense to refinance it :-)
Since Sunday - two days ago - 41 people downloaded it from my site. And some of them seem to click on the advertising inside the Window. At the moment, it shows Advertising about quads, those 4-wheeled-fun-mounts... Don't know, where Google gets the Info about me sticking to quads, but ok. :mrgreen:

So, I'd like to share my findings :-)
You will need an account over at Google Adsense, and about 1k on your own webspace for every ad-campaign you like to set up.
Then - in AdSense - set a campaign for online-content, get the appropriate ID and your publisher-id. You can use these two files:

Part 1: PureBasic-Code, self contained. This works on Mac OS X

Code: Select all

; AdSentified - means AdSense in your Desktop-Apps!
; made by The Crying Eye
; use it, share it, give credit (if you like)
; donate to some international organization planting trees :-)
; comments welcome

EnableExplicit

Global URLgotshot = 0
Global threadid = 0

Procedure  Open_URL(URL$)
  CompilerSelect #PB_Compiler_OS
    CompilerCase #PB_OS_MacOS   : RunProgram("open", URL$, "")
    CompilerCase #PB_OS_Windows : RunProgram(URL$)
    CompilerCase #PB_OS_Linux   : RunProgram(URL$)
  CompilerEndSelect   
EndProcedure

; I need to fake Callbacks here, because PureBasic does not actively support
; CallBacks from WebGadgets on Mac OS X (or I am too stupid to use it)

Procedure NavigationCallback(*value)
  Define temp$
  Repeat
    temp$ = GetGadgetItemText(0,#PB_Web_PageTitle)
    If temp$ <> "Apps" And temp$ <> ""
      Open_URL(GetGadgetText(0))
      URLgotshot = 1
    EndIf
    Delay(250) ; needs this to stop double or tripleclicks
  ForEver
EndProcedure 

OpenWindow(0,50,50,468,60,"Adsense")
WebGadget(0,0,0,468,60,"http://domain.com/yourhttpfile.html") ; set the URL and Size accordingly.
threadid = CreateThread(@NavigationCallback(),0)

Repeat
  If URLgotshot = 1
    SetGadgetState(0,#PB_Web_Back)
    URLgotshot = 0
  EndIf
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
Part 2: The HTML-file - Do not reformat, remove all comments added using // !!!

Code: Select all

<html><head><title>Apps</title></head><body><div style="position:fixed;top:0;left:0;width:486px;height:60px;padding:0;margin:0;overflow:hidden">
<script type="text/javascript"><!--
google_ad_client = "xxx"; // add your publisher-id here
/* Apps */  // you need to set the same name here like in your campaign
google_ad_slot = ""; // add your ad-slot here - the ID of your campaign
google_ad_width = 468; // the same size as in your PB-Code
google_ad_height = 60;
//-->
</script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div></body></html>
If statistics are right, I will earn 1 € per day. I don't know the real outcome atm, but that sounds promising. More income than selling the App!
I think, this will decline in the future, when less people download my App, but for now... Nice :-)

If you have more question, don't hesitate to ask.
This is hard to figure out, but easy to setup.
Regards,
JamiroKwai
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: Adsense in PureBasic-Apps

Post by rsts »

Interesting.

Many thanks for the code and idea :)
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Adsense in PureBasic-Apps

Post by wilbert »

Nice to hear that this is possible using PureBasic 8)
I considered it for my iOS apps but couldn't put myself to it since I hate ad-based apps myself :shock:
jamirokwai
Enthusiast
Enthusiast
Posts: 798
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: Adsense in PureBasic-Apps

Post by jamirokwai »

wilbert wrote:Nice to hear that this is possible using PureBasic 8)
I considered it for my iOS apps but couldn't put myself to it since I hate ad-based apps myself :shock:
Yes, I also do hate ad-based apps.

But since competition is strong, and has more money ...
Giving away apps for free, and incorporate ads in it sometimes is the only way.

I have to see it this way: Sometimes, it's better earning 10 bucks a week WITH advertising than 3 bucks SELLING the same app ... And this way, people find my other apps, too.

It's a pity, but the world seems to work like this :?
Regards,
JamiroKwai
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Adsense in PureBasic-Apps

Post by wilbert »

I understand that it can be an attractive method for a developer (just like in app purchases).

As for the navigation callback, this sort of mimics it a bit but I don't know if that would work for you.
http://www.purebasic.fr/english/viewtop ... 19&t=48917
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Re: Adsense in PureBasic-Apps

Post by Num3 »

Nice!
200 open tabs in 5 seconds!!! Had to hard reset pc...

A few years back there was a javascript virus that did just this...
jamirokwai
Enthusiast
Enthusiast
Posts: 798
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: Adsense in PureBasic-Apps

Post by jamirokwai »

Num3 wrote:Nice!
200 open tabs in 5 seconds!!! Had to hard reset pc...

A few years back there was a javascript virus that did just this...
Oh, that's odd. Which OS do you use?
I am on Mac OS X here.

Probably 250 msec delay isn't enough!?
Regards,
JamiroKwai
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Adsense in PureBasic-Apps

Post by c4s »

It's not allowed to include Google Adsense in software. This also applies when using a web gadget since its only purpose is to display the advertisment:
AdSense program policies -> Ad placement wrote:Google ads, search boxes or search results may not be:
  • Integrated into a software application of any kind, including toolbars.
  • Placed on any non-content-based page.
[...]
However it seems that this new service called Google AdMob is allowed as it has been created for apps...
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Adsense in PureBasic-Apps

Post by Polo »

Only for mobile, however.
jamirokwai
Enthusiast
Enthusiast
Posts: 798
Joined: Tue May 20, 2008 2:12 am
Location: Cologne, Germany
Contact:

Re: Adsense in PureBasic-Apps

Post by jamirokwai »

c4s wrote:It's not allowed to include Google Adsense in software. This also applies when using a web gadget since its only purpose is to display the advertisment:
AdSense program policies -> Ad placement wrote:Google ads, search boxes or search results may not be:
  • Integrated into a software application of any kind, including toolbars.
  • Placed on any non-content-based page.
[...]
However it seems that this new service called Google AdMob is allowed as it has been created for apps...
Damn... Thanks for the info.

I will contact Google to clarify.
Regards,
JamiroKwai
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Adsense in PureBasic-Apps

Post by IdeasVacuum »

I will contact Google to clarify.
Will be interesting to hear what they say - I mean, why limit the service to Mobiles (no screen estate!) and tablets?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply