The module 'SimpleAds' is kinda new and I can't find any documentation about it. The module looks pretty straight forward but for some strange, maybe stupid, reason I can't get the ad statistics to work.

I created a text ad and an image ad, as Admin I can see the tab 'ad statistics' but when I refresh or click on it as an anonymous user or as admin no counters go up.

I checked the permissions: "Count ad impressions" and "Count ad clicks" are checked for all roles.

Doesn't somebody have more documentation or an answer for this case?

Kind regards

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

minnur’s picture

Hi, Please try to remove the module from the site, clear the cache, run cron. And then try to install it again and see if you still can reproduce the issue.
Thank you.

minnur’s picture

Status: Needs work » Needs review
brahimmouhamou’s picture

Should you see the counters go up immediately?
Just removed it, cleared the caches, ran the cron, reinstalled it, created a simpe ad node.
Visited the ad as admin but also as anonymous.

Result: nothing, all counters stay on 0/0

Do I need to wait at least an hour before the first results are shown?

minnur’s picture

No, you don't need to wait, it should increase all counters immediately.
- Do you see any error messages in logs ?

minnur’s picture

I need more information from you in order to try replicate the problem.

brahimmouhamou’s picture

No, no errors in the logs.
I did put the ads in a views that is displayed in the sidebar.
I also can tell you that at the moment I'm using Drupal 7.8.

Is there other information that you like to have?

brahimmouhamou’s picture

Oh btw, I also tried the following: uninstalling the current simpleads module and installing the dev-version, same result: no incrementation.

brahimmouhamou’s picture

Status: Needs review » Needs work

Ok so because I didn't get response for a while I tried SimpleAds on a brand new drupal 7.12 installation and without success,
counters aren't going up, am I the only one having this problem?!

But I did get this message:

Strict warning: Only variables should be passed by reference in _simpleads_stat_tab() (line 14 of example.com/drupal/sites/all/modules/simpleads/simpleads.stat.inc).

minnur’s picture

Please check impressions/counts table in the database and confirm that the table has records.

Also please read this:

If your site is behind a reverse proxy (e.g. Varnish) the unique impressions
count will be incorrect because it will record the IP address of the proxy
rather than the client. Make sure you set variables 'reverse_proxy' and
'reverse_proxy_addresses' to suit your infrastructure.

brahimmouhamou’s picture

FileSize
39.82 KB

I'm not behind a reverse proxy so that won't be the issue.

But to respond to your first remark, I don't see anything in the tables:

The simpleads_clicks table is empty.

The simpleads_impressions table is empty.

Only the simpleads_blocks table has records.

SimpleAds Blocks Table

minnur’s picture

Enable "Count impressions" and "Count clicks" for anonymous users. Then open different browser and keep clicking ads and refreshing the page. MAKE SURE that you are not logged in.

brahimmouhamou’s picture

FileSize
17.88 KB

That's what I did the first time, and I just now repeated the process.
I also created a link into a text ad so that I can click on that link and on the ad title.
I'm logged in as admin in Chrome and am an anonymous user on Safari.
Still nothing changes, the tables are still empty.

Permissions

minnur’s picture

Can you show me redirection URLs ?

profak’s picture

Statistics works good in 1.7!

brahimmouhamou’s picture

Where can I look up these redirection urls?
I normally click on the title of the ad, so it redirects to a /node/[nr].

profak’s picture

rimbah, try to log out and you will see magic.
I think this behaviour just perfect. Admin always gets to advertisment node, where he can change settings, while simple users being redirected to redirection url.

brahimmouhamou’s picture

FileSize
12.25 KB

So I tried this when logged off but I still get the url: /node/[nr]
Then when I click it, I get redirected to the simplead node, it says the following:

access denied

minnur’s picture

Make sure that your ad url has http(s): in it. e.g http://google.com and not "google.com".

brahimmouhamou’s picture

Title: Why aren't the ad statistics work? » Why aren't the ad statistics working?

Ok first of all I only get the option for a redirection link if it's a image or flash ad.
So I tried the image ad, filled in the redirection url with 'http://www.google.com'.
Saved but when I hover the image in an other browser (not logged in) I just see the link /node/[nr].
No redirection done to my filled in link (google). Still links to the node and gives an Access Denied.

minnur’s picture

This is weird, at least it should show something like simpleads/redirect/[node_id] or simpleads/redirec/www.google.com in case if your link missing "http(s)://" (in 7.17 version, this is fixed in dev version).

minnur’s picture

Status: Needs work » Active
brahimmouhamou’s picture

Yez, I think that might be the problem from the start, in all my tests I never saw that redirection from simpleads, just /node/[nr]...
Just created another new install of drupal and installed SimpleAds... still I see /node/[nr] instead of the redirection to http://www.google.com.

I tested this in Chrome, Safari, IE and Firefox so it's not a browser issue.. :s

minnur’s picture

What's the default language of your site ?

minnur’s picture

and what does [nr] mean ?

brahimmouhamou’s picture

Language is English.

I used [nr] for 'the node id', ex. /node/23
should have used '/node/[nid]'

brahimmouhamou’s picture

Is there anything other I can check/do/test?

minnur’s picture

Could you write all the steps that you are doing to install SimpleAds ?

brahimmouhamou’s picture

  1. Go to modules and click 'install new module'
  2. Fill in the input field with the url of the install file
  3. After installation, go back to the modules page to enable it
  4. After enabling, go to permissions and enable 'Count ad impressions' for anonymous and authenticated user
  5. Do the same for 'Count ad clicks'
  6. Click 'Add new content', then click 'Simple Ad'
  7. Fill in the title, select 'Content Ad','Image Ad', choose a file and click on upload.
  8. Type in the url address 'http://www.google.com'
  9. Active date: 'now', End date: 'tomorrow' and click save
  10. Open other browser and go to home page where I click on the image (when not logged in)
  11. When I hover I just see /node/[nid], so when I click I visit the node page where I get 'Access Denied'
  12. Go back to the other browser where I'm logged in as Admin and go to the node ad page where I click 'ad statistics'
  13. Overlay appears with every counter on '0/0'
  14. Refresh a couple of times without success
minnur’s picture

hm, I have no idea why this happening to you.
Could you also try directly access redirection URL: http://yourisetname/simpleads/redirect/[ad_node_id] (as anonymous user).

brahimmouhamou’s picture

Hello again,

So I did what you asked me to and I got the following results.

1. Created a text ad and went to your url:

Text Ad

2. Created an image ad an went to your url which redirected me to google:

Redirect worked

So that seems to work, which means that the only thing we need to know is why we aren't getting the url-redirects when I create an ad?

minnur’s picture

Maybe you have older theme templates that overrides newer ones?

brahimmouhamou’s picture

Can't be as i use the original drupal theme and already checked the module with a new clean install.

minnur’s picture

Any update on this issue?

brahimmouhamou’s picture

Nope, was busy creating another website, just installed simpleAds there but still when I hover the image, it gives me yoursite.com/node/[ad_node_id]
Changed the themes: Batrik, Garland and Stark, they all give the same url, don't see any redirection.

minnur’s picture

I am sorry that I wasn't able to help you with this. Currently I am extremely busy on some big projects and most likely I can take a look at this next month.
Please keep me posted.

Thanks,

Minnur

brahimmouhamou’s picture

I think I know the problem. When you create a node, it gets displayed on the frontpage automatically.
I was always testing the ad on this published frontpage or in a views-block made by myself. Is it possible that it's normal that in those cases the redirect will not work?

Incredibly stupid but it was the first time now I tested the ad by using the block already predefined in the blocks section:
- block: content ads
- block: sidebar ads

And when I use one of those it works perfectly!!

minnur’s picture

Status: Active » Closed (works as designed)

Thanks for the update. I am closing this issue.

dgtlmoon’s picture

Version: 7.x-1.7 » 7.x-2.x-dev
Component: Documentation » Code
Category: support » bug
Status: Closed (works as designed) » Active

Seems to be active again in the 7.x-2.x-dev snapshot, atleast from today.

I have uploaded an image and given it a destination URL, ie http://google.com/

but the link on the image goes directly to http://google.com, no stats or redirects are present, The stats page for the node just has the headers for the stats table and no data/rows

dgtlmoon’s picture

Priority: Critical » Normal

Ehhh i'm starting to think this is a different issue, it could be the lack of documentation that's causing the issue

+-----+-------+------------+----------------+------+
| aid | nid   | timestamp  | ip_address     | url  |
+-----+-------+------------+----------------+------+
|   1 | 98622 | 1371654559 | 123.23.123.123   | NULL |
|   2 | 98622 | 1371678945 | 123.123.123.123 | NULL |
|   3 | 98622 | 1371681377 | 123.123.123.123 | NULL |
+-----+-------+------------+----------------+------+
3 rows in set (0.17 sec)

I'm seeing some stats in the table, but the is going directly without any redirect, so i guess there must be some other hook going on?

however stats arent showing on that page just yet, really confusing :/ sorry

dgtlmoon’s picture

Component: Code » Documentation
dgtlmoon’s picture

Ads show up after some time, tho not after running the cron job directly (using ultimatecron) must be some other rule that triggers them

duntuk’s picture

It's only running on cron if the date is different (not including time). Meaning, every 24 hours it collects statistics.

if ( date( 'm-d-Y', $timestamp ) != date( 'm-d-Y', REQUEST_TIME ) ) {
minnur’s picture

Issue summary: View changes
Status: Active » Needs review

dgtlmoon, thanks for clarification.

bjlewis2’s picture

Is it possible to get statistics sooner than the next day? ie: hourly like the 1.8 version does?

chrisdkemper’s picture

So I've been looking at this, because I'm reviewing the module for a client.

I've looked through the code, and as duntuk mentioned, it's only updating the stats once a day. This is a huge problem, because if you run cron frequently (as this client does) The first run will then lock out anymore stats updates for the whole day, so a lot of the ads will never disable. I've looked in the code, and the only insert reference to the `simpleads_stats` is in the cron hook.

In my case, my impressions and clicks are recording, but because the simpleads_stats only gets updated on cron, and all of the checks to display the stats or hide the ads depend on this table, it's a huge problem. There needs to be a hook on every impression/click that's recorded that does the job of the following in the cron hook.

db_merge('simpleads_stats')
      ->key(array('nid' => $row->nid, 'date' => $row->date))
      ->fields(array(
        'nid' => $row->nid,
        'date' => $row->date,
        'clicks' => 0,
        'clicks_unique' => 0,
        'impressions' => $row->all_count,
        'impressions_unique' => $row->unique_count,
      ))
      ->execute();

I haven't looked at the 1.8 version, but it seemed to have actively updated stats (when it worked) and also showed the hourly stats. Now the module only works in 24hr intervals, which for sites that have a lot of traffic and rely on the click/impression limits, this won't work.

For my review purposes, this module is the only one that really fits the need, but to use it, I'd need to fix it, and I'm not sure the client will pay me to do that, sadly.

FranCarstens’s picture

I attempted to access the redirect url directly using the format http://mysite/simplads/redirect/[nid] but this failed. After taking a look in simpleads.module I noticed the following:

<?php
    $items['node/%node/stats/redirect'] = array( 
?>

I adjust my view URL rewrite to read a href="/node/[nid]/stats/redirect" and that worked.

I'll see tomorrow (on daily cron?) if those clicks were actually tracked though.

FranCarstens’s picture

@chrisdkemper, I'm not a developer but a quick look in the module makes me wonder, wouldn't changing the following lines (in cron.inc) change when stats are aggregated?

19 | WHERE FROM_UNIXTIME(s.timestamp, '%Y-%m-%d') BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 SECOND
...
50 | WHERE FROM_UNIXTIME(s.timestamp, '%Y-%m-%d') BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 SECOND
ahmed.raza’s picture

Hi, i am having the same problem. Everything was working fine on live site, then suddenly the module stopped tracking the stats of ads. Im using version 7x.1.8

esolano’s picture

Hi all,

We're currently using Simpleads 7.x-2.x-dev on a client's site. He is reporting the print stats are not matching what google analytics shows (total prints on a page where my ad shows up). After looking into some reported issues, and analyzing the code for a while, we got to the conclusion that the current way stats are being aggregated might be causing the issue, specially if cron is run once a day. Here's why:

If cron runs once a day, it retrieves all prints from a day ago, but only that day, leaving out all today’s prints. So say we run cron today at 10pm (today is 2018-04-11). The FROM_UNIXTIME(timestamp, '%Y-%m-%d') BETWEEN CURDATE() - INTERVAL 1 DAY AND CURDATE() - INTERVAL 1 SECOND where clause would be between 2018-04-10 and 2018-04-10 23:59:59; but leaving out all today’s prints since 2018-04-11 00:00:01. Then it will aggregate yesterday's data, and wipe out all prints for any ads aggregated. This cycle repeats every day.

As you can see, there will be data lost (not aggregated) every day. The next day it will aggregate all data from 2018-04-11 to 2018-04-11 23:59:59, but without the prints that were deleted.

We worked on a patch that we're still testing, based on https://www.drupal.org/project/simpleads/issues/2449663#comment-11124609, but adjusted to work in version 7.x-2.x. It seems to be working for us.

I hope this helps solve this issue.

Regards.

Status: Needs review » Needs work

The last submitted patch, 49: simpleads_ad_stats_not_working_1436134_49.patch, failed testing. View results

esolano’s picture

Fixing small issue in #49 patch from automated test.

esolano’s picture

minnur’s picture

Status: Needs work » Closed (won't fix)