AdSense is a free program that gives you a fast and easy way to display relevant Google ads on your result pages. When users click on an ad in your search results, you get a share of the ad revenue. For more information about AdSense, see the Help Center.
If you don’t have an AdSense account, you can apply for one by going to Google AdSense website. If you already have an AdSense account, don’t create a new one; just associate the existing one with your search engine. All search engines in your account will automatically be associated with that AdSense account.
You can also associate your existing AdSense account with your search engine in the context file by following these steps:
- Find your AdSense ID.
- Associate the AdSense publisher ID with the search engine.
Finding Your AdSense ID
If you already have an AdSense account, you can find your unique AdSense publisher ID by signing in to your AdSense account. Your publisher ID number is above the help search box in the top corner. Alternatively, you can find your publisher ID within the generated AdSense code that you insert in the HTML code of your webpage. Locate the line that has: google_ad_client="pub-1234567890123456"
; the number is the ID.
Associating a Search Engine with an AdSense Account
To associate a search engine with an AdSense account, add the AdSense
element in the XML specification (the context XML file), like this:
<CustomSearchEngine id="my_first_cse" creator="0123456789" keywords="cars" language="en"> <Title>Automobile Search</Title> <Description>Car Search</Description> <Context> <BackgroundLabels> <Label name="_cse_my_first_cse" mode="FILTER" /> <Label name="_cse_exclude_my_first_cse" mode="ELIMINATE" /> </BackgroundLabels> </Context> <LookAndFeel nonprofit="false" /> <AdSense> <Client id="pub-9876543210" /> </AdSense> </CustomSearchEngine>
The XML has the following hierarchy:
CustomSearchEngine
Title
Description
Context
LookAndFeel
AdSense
Client id