My code looks like this:
ORIGINAL
var key_word = {'dentists'};
var pageOptions = {
'query': 'cars',
'hl': 'en'
};
I want to insert the variable ‘key_word’ into where it says cars:
NEW CODE – entire code
<div id="adcontainer1"></div>
<script src="http://www.google.com/adsense/search/ads.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
var key_word = "dentists";
var pageOptions = {
'pubId': 'pub-999999999999999',
'query': function(){ return key_word; },
'hl': 'en'
};
var adblock1 = {
'container': 'adcontainer1',
'number': '1',
'width': '700px',
'lines': '1',
'colorBackground': 'FBFFDB'
};
new google.ads.search.Ads(pageOptions, adblock1);
</script>
From the resulting ad, it appears dentists is not being passed correctly. Instead the ad is running the text ‘key word’ instead of the variable key_word, which is the text ‘dentists’. Do I have a syntax problem here?
I think you want something like this.