I installed the AdSense module (wonderful! wonderful!) with revenue sharing enabled on my site without any problems following the instructions. Everything seems to be working fine (displays, etc.). However, when I go to test mode (signing out), I can only see my client ID on ads throughout the site. I don't have much experience with PHP or programming, although I have no problem giving things a try. I was doing fine up to this point, now I think I have met my match and have to ask the pros.

I have already tried the following without any success:

1. Cleared cookies.
2. Cleared AdSense cache.

I use Drupal 5.1.

Any help would be much appreciated.

Thanks!
HeavilyMental

CommentFileSizeAuthor
#4 compare.gif25.23 KBPetra
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Petra’s picture

Title: AdSense displaying owner ads only » revenue-sharing not always working

I have a similar problem.
I use drupal 5.1, adsense.module 5.x-1.3 with adsense_injector.module 5.x-2.5-1, php 4.4.4.
cache is disabled, all publisher-ids are registered and revenue-sharing is 50/50. I can see the publisher-ids in testmode (logged out). I inserted asense by adsense injection and adsense-tag ([adsense:format:group:channel]).

I have articles, with which the publisher-ID changes, as she is to change for my attitudes accordingly. In addition, I have articles with those the publisher-ID is always the siteowner publisher-ID. But I can't recognize any difference between these articles.

With the articles, with which the publisherID does not change, in
function adsense_get_client_id ($uid = false, $type = false) {
no $uid is available, even if infunction adsense_nodeapi $ui is available.

function adsense_nodeapi(&$node, $op = 'view', $teaser, $page) {
switch($op) {
case 'view':
if ($page) {
echo $node->uid; -> 21

function adsense_get_client_id($uid = false, $type = false) {
echo $uid; -> no value

If I write into adsense_get_client_id the value of $uid from function adsense_nodeapi, then publisher-ids are changed, as they are to be changed.

I do not have an idea which the cause be can. I emptied the cache, I emptied the session-table and I let again develop the authorizations for articles - makes all no difference. I deactivated and again activated Adsense and Adsense injection - also this does not make a difference.

Does someone know what the cause can be? And how I can repair the articles?

Petra’s picture

Title: revenue-sharing not always working » AdSense displaying owner ads only

sorry, I changed the title - and I hope I change it back now. (Who can read, is in the advantage ;-(

kbahey’s picture

Petra

You are on the right track to debug this.

Add more prints in adsense_get_client_id() to see if the $client variable is cached.

Petra’s picture

FileSize
25.23 KB

(excuse the late answer - I had to play windows first :(( and then tested a lot)
(in the attached picture online is linux - local is windows xp, but I don't think it is important for the $client variable. There is no difference between local and online)

With Google AdSense Injector I inserted an inline-ad in node-body on pageviews (

[adsense:468x15:1:1]

%body) - so all nodes have adsense at the begin of the text.
(I placed it at the end of the text - makes no difference for client-id)
(I switched of the adsense-tag per injection - also makes no difference for client-id)
(I disabled adsense-injection - also makes no difference for client-id)

All nodes have this filters:
URL filter - weight 0
line-break - weight 1
AdSense tag - weight 10 (or weight -10 - makes no difference for client-id)

I added prints for function-name, $uid and $client. In the picture I attached I can see - when revenue-sharing is working - adsense_get_client_id is first called from adsense_nodeapi where $uid has a value. So adsense_choose_client gets the $uid and tosses the dice for the client.

adsense_nodeapi is called two times, at first time with $op = load and at second time with $op = view.
Between the calls of adsense_nodeapi adsense_filter is called.

when it doesn't work:

adsense_filter calls _adsense_process_tags
case:tags calls adsense_display
adsense_display calls _adsense_check_if_enabled() which calls adsense_get_client_id() (with no argument)
so $uid is not availible -> site-client is cached as $client

when adsense_nodeapi is called with $op = view and calls adsense_get_client_id, $client is already cached.

when it works:

adsense_filter calls _adsense_process_tags
nothing happens (cause there is no adsense-tag in the text)

when adsense_nodeapi is called with $op = view and calls adsense_get_client_id $uid is available and no $client is already cached.

=> the difference was the adsense-tag ([adsense:format:group:channel]) in the text. Do I insert one, revenue-sharing is not working, do I only use adsense-injection, revenue-sharing works fine.

But the adsense-module is made for adsense in text - so what can I do?
(I added adsense_get_client_id($node->uid, $node->type); as first line in adsense_nodeapi -> revenue-sharing works fine - but I don't think that's the solution.)

kbahey’s picture

Thanks for the nice and thorough analysis. Wish all bug reports were like that. Only next time, just include the text itself within <code> tags. That should be easier and more readable, unless you are taking a screen shot.

One more test to do. Forget adsense injector. Forget tags.

Just configure a block, and then do the same analysis, and see if the revenue sharing works that way or not.

Petra’s picture

Revenue-sharing works:
I disabled Adsense Injection and removed all adsense-tags from content.
I added an adsense-block at the top of the content. (I also tested to placed it at the bottom and in the left sidebar)
I added new nodes - every node (old and new) shares revenue, local and online.

(I hope I understood what you meant with: place text within <code> tags )

adsense_nodeapi
  node->uid: 22
  op: load
end of adsense_nodeapi

  adsense_filter calls _adsense_process_tags
  foreach(patterns as mode => pattern)
  mode: flexi - no match - nothing else is called
  mode: block - no match - nothing else is called
  mode: tags - no match - nothing else is called

adsense_nodeapi
  node->uid: 22
  op: view
  case:view
  page: 1
  node->uid: 22
adsense_get_client_id
  uid: 22
  client:
  site_client: pub-4569642605643069
  revenue: 1
  _adsense_choose_client
  uid: 22
  revenue_enable: 1
  referral_client: pub-8030388913428713
  author_client: pub-8030388913428418
  random: 56
  client after _adsense_choose_client: pub-8030388913428713
end of adsense_get_client_id
end of adsense_nodeapi
kbahey’s picture

This means that the problem is either in the tags, or in the adsense injector module (which is a separate module).

You can try to isolate the matter further by having a block AND a tag inside a node on the same page, and see if both show the same adsense ID, and whether it is the correct ID (e.g. one page view it would be for the site owner, one page view it would be for the author).

This way we know whether to transfer this issue to the adsense injector module, or to investigate the tags as the source of the problem.

Petra’s picture

I think the tags are the source of the problem.
I added a tag inside a node and have also a block and get this (only site-client-id is used in every ad on every page view)

adsense_nodeapi
  node->uid: 11
  op: load
end of adsense_nodeapi

  adsense_filter calls _adsense_process_tags
  case:tags calls adsense_display

adsense_display
adsense_get_client_id
  uid:
  client:
  site_client: pub-4569642605643069
  revenue: 1
  _adsense_choose_client
  uid:
  revenue_enable: 1
  referral_client:
  author_client:
  client after _adsense_choose_client: pub-4569642605643069
end of adsense_get_client_id

adsense_get_client_id
  uid:
  client: pub-4569642605643069

adsense_nodeapi
  node->uid: 11
  op: view
  case:view
  page: 1
  node->uid: 11
adsense_get_client_id
  uid: 11
  client: pub-4569642605643069
end of adsense_nodeapi

adsense_filter() is called at every page view - if there are tags or not. And this function - when a tag is in the text - calls adsense_display() which calls adsense_get_client_id() with no argument, so $uid is not available, only site-client can be choosed and the function caches $client. So whatever happens after, $client won't change.
And I always have the same adsense ID for all adsense-ads (block and tag) in one page view. I never have different client-ids in the ads (for example site-client in block and author-client in the tag).

When I use adsense-injection (also with a block) it works like the code in my last posting: $client changes and also referral_client is used.

kbahey’s picture

Title: AdSense displaying owner ads only » Adsense with revenue sharing displaying only the owner's ID.
Version: 5.x-1.3 » 5.x-1.x-dev
Assigned: HeavilyMental » kbahey
Category: support » bug
Status: Active » Needs review

I put a fix for this in the 5.x development branch, so wait for 12 hours, and then download the tarball, and it should work.

Once you confirm that it is working, I will roll out a proper official release, and replicate to HEAD.

Petra’s picture

Great - it works!!!
I didn't add all the prints like before - I looked at the publisher-IDs displayed in testmode, when I'm logged out.
I works for all combinations of block, adsense-injection and tags. It works for old nodes and new added nodes, also for refferal_client (and local and online).

Thanks a lot!!! :-)

kbahey’s picture

Status: Needs review » Fixed

Fixed in HEAD and 5.x.

Thanks for the details.

HeavilyMental’s picture

Version: 5.x-1.x-dev » 5.x-1.4

My installation is still not working correctly after installing the latest update. It still only shows the owner ID on the other nodes. I disabled AdSense injector, and I only have the latest version of this module (5.x-1.4) installed. Is there any other information I can provide to help?

kbahey’s picture

Here is the scenario:

Site owner (uid 1) has a google ID of USER1
user 2 (uid 2) has a google ID of USER2

User 2 creates a node of type page.

Adsense revenue sharing has 50/50, and enabled for page.

Say user 2 creates node/2.

If you setup test mode, log off, and then visit node/2, you should see USER2 50% of the time, and USER1 the rest of the time.

You can go into the function adsense_get_client_id(), and add a print before each return, to see how far the module goes and what it is doing.

Other than that, I have no idea to narrow that down. It works for me, as well as Petra.

HeavilyMental’s picture

KB, I am with you on all of that.

I added the prints as you suggested to a test installation.

I originally only had one AdSense block in the right sidebar, like on my live site, and nothing changed. However, when I added an additional AdSense block to the left sidebar and another one into the header and reloaded, the client IDs changed like I had set up (50/50) in the user2 node. However, if there was only one AdSense block, it never changed.

I looked at it on both Safari and Firefox.

Afterwards, I added the same blocks in my main site, but the client ID never changed when I went to a user's node that had an AdSense client ID.

I am also using Pathauto and URL Alias and am wondering if these are not compatible with the AdSense module? Could that be the problem?

HeavilyMental’s picture

Sorry...wanted to clarify last post...

I use Pathauto and URL Aliases on my live site, and did not install on the test site.

Petra’s picture

I also tried it: only one Adsense block in the right sidebar: client IDs change.
(I use Pathauto and URL Alias.)

kbahey’s picture

I used both a block and a tag in a node, set the sharing to 50/50 and went into test mode.

Then I navigated to the node (because sharing only works when you are viewing the nodes), and I saw the ids change.

I also setup an alias for that node and it still does revenue sharing correctly.

HeavilyMental’s picture

You are correct. And you are both AWESOME! Thank you for all your hard work! Works great now!

kbahey’s picture

What was it that made it work for you?

HeavilyMental’s picture

KB, I am not quite sure. After your last post I took the extra AdSense blocks back out and went back to my original of just one in the right sidebar. Then I checked it again and after a number of reloads, I saw the IDs changing. I wish I could be of more help than that. :(

Petra’s picture

Possible - sometimes I must reload the page up to five times till IDs change.
And perhaps the php-Version is important: since PHP 4.2.0 it is not necessary to use mt_srand() bevor mt_rand().

HeavilyMental’s picture

Somehow the problem has reappeared. The client IDs aren't changing again on my live site, but they do on a test site. I have compared the test adsense.module to the live adsense.module and they appear to be the same.

Could it be a theme problem? Could it be because I am using a Mac to edit offline (TacoHTML Edit) and it is adding something extraneous to the files (although I am editing though cPanel online, for the most part).

I am using PHP 5.0.5.

Thanks for the help.

Anonymous’s picture

Status: Fixed » Closed (fixed)
edialogue’s picture

Version: 5.x-1.4 » 6.x-1.2
Category: bug » support
Priority: Normal » Critical
Status: Closed (fixed) » Active

Please help. I use Adsense with sharing. I built my site with Drupal 6 but Adsense sharing is not working. It shows only my ID and not anyone else no matter who posted the article. I have followed the instructions but no difference. What do I do?

kbahey’s picture

Priority: Critical » Normal
Status: Active » Closed (fixed)

Do not open closed issues. Marking something as critical does not make it automatically so.

See here for the real issue with revenue sharing with Google's post October 2008 code.

#293206: Revenue Sharing using Google's new Managed Ads script