Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Community Discussions (All other subjects)
 Google Adsense
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 8

TestMagic
Senior Member

USA
1568 Posts

Posted - 28 June 2003 :  15:33:42  Show Profile  Visit TestMagic's Homepage
quote:
Originally posted by jfitz

That's a good point Gremlin. I've found the appropriate changes to make to inc_header.asp that handle the GoogleBot as well as the disallowed pages. I'd be happy to post them if someone is interested. Just let me know where the appropriate location would be.

Yeah, I'd like to know how to exclude the ads from search.asp and maybe even post.asp (just for the heck of it).

Snitz rocks! · Search 2
Go to Top of Page

jfitz
Junior Member

USA
345 Posts

Posted - 28 June 2003 :  15:52:19  Show Profile
Wherever you put the JavaScript (I'm assuming it's in inc_header.asp) for the Google AdSense ads, just wrap this around it as shown. Add another clause to the check for any page you want to exclude (note that I also excluded my chat-room page):


'## GOOGLE ADSENSE PAGE CHECKS AND JAVASCRIPT HERE
if not(Instr(Request.ServerVariables("Path_Info"), "register.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "policy.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "pop_profile.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "fitnesschat.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "search.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "login.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "password.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "rules.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "faq.asp") > 0) then
   GoogleAdOK=TRUE
else
  GoogleAdOK=FALSE
end if 
if GoogleAdOK=TRUE then 
  Response.Write "<center>"
  %>
  <script language="JavaScript">
  <!--
  google_ad_client = 'YOUR GOOGLE PUBLISHER CODE GOES HERE';
  google_ad_width = 468;
  google_ad_height = 60;
  google_ad_format = '468x60_as';
  // -->
  </script>
  <script language="JavaScript"
    src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  </script>
  <%
  Response.Write "</center><br>" & vbNewLine		
end if


It would probably be cleaner if I used an include file for Google's JavaScript, but I didn't take that extra step.

--Jördan
It's a wasted day if you don't spend at least part of it flying upside down.

Edited by - jfitz on 28 June 2003 16:06:56
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 28 June 2003 :  22:04:53  Show Profile  Visit Gremlin's Homepage
I kind of took the opposite route and just used this code to only display it on the main forum pages


        <% If Request.ServerVariables("URL") = "/forum/default.asp" or _
		Request.ServerVariables("URL") = "/forum/topic.asp" or _
		Request.ServerVariables("URL") = "/forum/forum.asp" then

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

PeeWee.Inc
Senior Member

United Kingdom
1893 Posts

Posted - 29 June 2003 :  04:42:46  Show Profile  Visit PeeWee.Inc's Homepage
Someone should whip this up into a MOD.

Maybe with a Admin side to pick what pages to show the Adds on.


De Priofundus Calmo Ad Te Damine
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 29 June 2003 :  05:08:56  Show Profile  Visit Gremlin's Homepage
Actually I probably will turn it into a mod next week sometime, just have some more urgent things to complete first.

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

jfitz
Junior Member

USA
345 Posts

Posted - 29 June 2003 :  10:37:10  Show Profile
The other half of the equation is allowing Google to crawl your forum if it's password protected. I checked with Google and they provided the HTTP_USER_AGENT code that they use in their AdSense robot, so I made the following changes to inc_header.asp so that if the Google robot is detected, it is synthetically logged in. I actually created a forum registration for the Googlebot, but I don't believe that this step is actually necessary.

The following changes check for the Google AdSense crawler and synthesize a logon, skipping the actual logon in the process. One danger is that the Googlebot header could be spoofed, which is why I elected to add a separate registration for the GoogleBot.


INC_HEADER.ASP

Around line 170, find this code

strDBNTUserName = Request.Cookies(strUniqueID & "User")("Name")
strDBNTFUserName = trim(chkString(Request.Form("Name"),"SQLString"))
if strDBNTFUserName = "" then strDBNTFUserName = trim(chkString(Request.Form("User"),"SQLString"))
if strAuthType = "nt" then
	strDBNTUserName = Session(strCookieURL & "userID")
	strDBNTFUserName = Session(strCookieURL & "userID")
end if

Add this code IMMEDIATELY BEFORE it

'## GOOGLE ADSENSE AUTO LOGON
strGoogle = Request.ServerVariables("HTTP_USER_AGENT")
if Left(strGoogle,21) = "Mediapartners-Google*" then
   mLev=1
'SET THE MEMBER ID TO SOMETHING APPROPRIATE FOR YOUR FORUMS 
'THE MEMBER ID SHOULD CORRESPOND TO A REGULAR MEMBER
'I CREATED A SEPARATE REGISTRATION BUT IT REALLY ISN'T NECESSARY
   MemberID=2679
   AllowGoogle=TRUE
else
   mLev=0
   MemberID=0
   AllowGoogle=FALSE
end if
  
'## GOOGLE ADSENSE AUTO LOGON
if AllowGoogle<>TRUE then


Around line 240, find this code

if mLev = 4 and strEmailVal = "1" and strRestrictReg = "1" and strEmail = "1" then
	'## Forum_SQL - Get membercount from DB 
	strSql = "SELECT COUNT(MEMBER_ID) AS U_COUNT FROM " & strMemberTablePrefix & "MEMBERS_PENDING WHERE M_APPROVE = " & 0

	set rs = Server.CreateObject("ADODB.Recordset")
	rs.open strSql, my_Conn

	if not rs.EOF then
		User_Count = cLng(rs("U_COUNT"))
	else
		User_Count = 0
	end if

	rs.close
	set rs = nothing
end if


Add this code IMMEDIATELY AFTER it

'## GOOGLE ADSENSE AUTO LOGON
end if


I didn't post this in the MOD forums because without the other half (selective pages), it isn't complete. I can put the two halves together if someone wants.

Gremlin, if you want to take this code, and use / improve it, you are welcome to do so.

--Jördan

--Jördan
It's a wasted day if you don't spend at least part of it flying upside down.
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 29 June 2003 :  11:20:25  Show Profile  Visit Gremlin's Homepage
I've got quite a bit of "paying" work to get done this week, feel free to release a mod yourself if you want, looks like your most of the way there now anyway, good work :)

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

jfitz
Junior Member

USA
345 Posts

Posted - 30 June 2003 :  11:49:40  Show Profile
quote:
Originally posted by jfitz

'## GOOGLE ADSENSE AUTO LOGON
strGoogle = Request.ServerVariables("HTTP_USER_AGENT")
if Left(strGoogle,21) = "Mediapartners-Google*" then
   mLev=1




Checking my server logs this morning, I discovered that I misinterpreted the email that Google sent to me about their HTTP_USER_AGENT: They said that the USER_AGENT would be "Mediapartners-Google*" and I foolishly took the asterisk as a literal and not as part of a regular expression. Consequently the code I posted is incorrect. The correct test is as follows:

strGoogle = Request.ServerVariables("HTTP_USER_AGENT")
if Left(strGoogle,20) = "Mediapartners-Google" then
   mLev=1


Now that I've verified the USER_AGENT in practice, I'll put together the necessary MOD code and post it in the regular MODS with code forum.

--Jördan

--Jördan
It's a wasted day if you don't spend at least part of it flying upside down.

Edited by - jfitz on 30 June 2003 11:52:56
Go to Top of Page

work mule
Senior Member

USA
1358 Posts

Posted - 31 July 2003 :  18:30:48  Show Profile
quote:
Originally posted by jfitz

The other half of the equation is allowing Google to crawl your forum if it's password protected.


If your forum is password protected, you should make sure you make it so that someone can't view the page using the cache link in the search results.

http://www.google.com/webmasters/faq.html#cached

7. How should I request that Google not return cached material from my site?

Google stores many web pages in its cache to retrieve for users as a back-up in case the server where the page resides temporarily fails. Users can view the cached version by choosing the "Cached" link on the search results page. If you don't want your content to be accessible through Google's cache, use a <META> tag with a CONTENT="NOARCHIVE" attribute. To do so, place the following line in the <HEAD> section of your documents:

<META NAME="ROBOTS" CONTENT="NOARCHIVE">

This tag tells robots not to archive the page. Google will continue to index and follow links from the page, but will not present cached material to users. If you want to allow other robots to cache your content, but prevent Google's robots from doing so, use the following tag:

<META NAME="GOOGLEBOT" CONTENT="NOARCHIVE">

Please note that the change will take effect the next time Google crawls the page containing the NOARCHIVE directive in a <META> tag. If you want this change to take effect sooner, the site owner must contact us and request immediate removal of archived content. Note also that the NOARCHIVE directive only controls whether a cached version of the page is made available. To control whether the page is indexed, use CONTENT="NOINDEX". To control whether links are followed, use CONTENT="NOFOLLOW". For more information, see the Robots Exclusion page.


quote:
Originally posted by jfitz


'## GOOGLE ADSENSE PAGE CHECKS AND JAVASCRIPT HERE
if not(Instr(Request.ServerVariables("Path_Info"), "register.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "policy.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "pop_profile.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "fitnesschat.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "search.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "login.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "password.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "rules.asp") > 0) and _
   not(Instr(Request.ServerVariables("Path_Info"), "faq.asp") > 0) then
   GoogleAdOK=TRUE
else
  GoogleAdOK=FALSE
end if





You could simplify the above with this.

Set the Request.ServerVariables("Path_Info") to a variable and then reference the variable.


Dim strFileName
strFileName = Right(strScriptName, (Len(strScriptName)-InstrRev(strScriptName,"/", -1, 1)))

Select Case LCase(strFileName)
   Case "register.asp", "login.asp", "logout.asp", "policy.asp", "password.asp", "unsubscribe.asp"
      GoogleAdOK=TRUE
   Case Else
      GoogleAdOK=FALSE
End Select
Go to Top of Page

mama2000
Junior Member

Canada
100 Posts

Posted - 28 August 2003 :  21:28:44  Show Profile  Visit mama2000's Homepage
I added my google to an include file, and have burst in another. Here's what I did with you code.. BTW Thanks for the great help here!! I was wondering how to get this working. I have made 10X more with adsense than the others combined and didn't even have it on all my pages!


'## GOOGLE ADSENSE PAGE CHECKS AND JAVASCRIPT HERE
if not(Instr(Request.ServerVariables("Path_Info"), "register.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "policy.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "pop_profile.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "search.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "login.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "password.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "rules.asp") > 0) and _
	not(Instr(Request.ServerVariables("Path_Info"), "faq.asp") > 0) then
   GoogleAdOK=TRUE
else
  GoogleAdOK=FALSE
end if 
if GoogleAdOK=TRUE then 
  %>
<!--#INCLUDE VIRTUAL="include_adsense_code.asp" -->
  <%
else
  %>
<!--#INCLUDE VIRTUAL="include_other_code.asp" -->
  <%		
end if

:)
Kelly

http://atruckerswife.com/community/
Go to Top of Page

mama2000
Junior Member

Canada
100 Posts

Posted - 28 August 2003 :  21:43:51  Show Profile  Visit mama2000's Homepage
perhaps I posted too soon.. I am thinking that the other way is the way to go. This list does not exclude pages like private messages or admin, not to mention all the mods others may have added as well. I'll have a go at the 'include these pages' instead of 'exclude these pages' later...

:)
Kelly

http://atruckerswife.com/community/
Go to Top of Page

mama2000
Junior Member

Canada
100 Posts

Posted - 28 August 2003 :  22:17:27  Show Profile  Visit mama2000's Homepage
Thanks Gremlin and jfitz...

I used what you both had here and this is what I used:
Includes google include file on main forum pages, and used an alternative include file for other advertising on non included pages.

This place is the best!!


'## GOOGLE ADSENSE PAGE CHECKS AND JAVASCRIPT HERE
if Request.ServerVariables("URL") = "/forum/default.asp" or _
   Request.ServerVariables("URL") = "/forum/topic.asp" or _
   Request.ServerVariables("URL") = "/forum/forum.asp" then
   GoogleAdOK=TRUE
else
  GoogleAdOK=FALSE
end if 
if GoogleAdOK=TRUE then 
  %>
<!--#INCLUDE VIRTUAL="include_adsense_code.asp" -->
  <%
else
  %>
<!--#INCLUDE VIRTUAL="include_other_code.asp" -->
  <%		
end if


:)
Kelly

http://atruckerswife.com/community/
Go to Top of Page

Gremlin
General Help Moderator

New Zealand
7528 Posts

Posted - 29 August 2003 :  03:26:27  Show Profile  Visit Gremlin's Homepage
Glad to have been of some help :)

Kiwihosting.Net - The Forum Hosting Specialists
Go to Top of Page

jfitz
Junior Member

USA
345 Posts

Posted - 02 September 2003 :  10:32:24  Show Profile
Glad it's working well for you. We've also had really good results with Adsense.

--Jördan
It's a wasted day if you don't spend at least part of it flying upside down.
Go to Top of Page

laser
Advanced Member

Australia
3859 Posts

Posted - 02 September 2003 :  17:54:11  Show Profile
I applied 2.5 days ago, and just got the good old "difficult navigation and broken links" - LOL on the navigation, but I have some broken links I will fix before pushing them again
Go to Top of Page
Page: of 8 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 1.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07