Real-time reporting and disabling of campaigns when impression/click limit reached

Created on 28 August 2015, about 9 years ago
Updated 9 June 2023, over 1 year ago

We ran into two issues which we believe this patch solves.

First, when viewing a campaign (admin/content/simpleads_campaigns/[nid]), the "Clicks Left" and "Impressions Left" columns are misleading because they only include the clicks and impressions that happened on previous days. This causes confusion for our clients, because they don't see the click and impression numbers changing in real time. This one is mostly a display issue that causes confusion for the client (and by the look of the issue queue for this module, it causes confusion for a lot of devs as well).

Second, and most importantly, this bug allows campaigns to exceed their click and impression limits. In the following situation, the module will wrongly continue to show ads from the given campaign:

Campaign A has a limit of 1000 clicks. As of the end of day yesterday, it only had 2 clicks left. If it was working properly, when I receive my second click today around 1am, then the campaign is complete and the ad should stop showing. However, since the code only counts the clicks and impressions at the end of each day, this ad could receive 100 more clicks today and not be disabled until tonight at midnight. This is obviously not desired behavior.

The following patch makes the same change to the two methods which count the current number of clicks and impressions. Happily, this solves both problems described above. The methods are _simpleads_campaigns_count_ad_impressions() and _simpleads_campaigns_count_ad_clicks().

Previously, those methods would do a simple select from the simpleads_stats table which holds the aggregated data for previous days. We changed them to use a more complex select query which combines that information with the information for the current day. This means, every unique impression or unique click is reflected in real-time when viewing the campaign in the admin interface and when the campaign reaches the impression or click threshold the campaign will immediately end.

πŸ› Bug report
Status

Closed: won't fix

Version

1.9

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States kennywyland

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024