How to define a specific order in a group

If you combine ads in our Ordered group type, Advanced Ads will check them in the given order. The first ad that is checked with a positive result is also displayed.

Some users expect this group to rotate ads evenly, e.g., show ad #1 first, then ad #2, #3, etc., and finally start again with #1.

While this is not the default behavior, it is possible to build such an order with Advanced Ads Pro following the tutorial below.

I am demonstrating an example based on three ads. You can extend it to any number of ads.

Adding the rotation

In this tutorial, I am saving the last ad the user saw from a group in a cookie and showing the next one based on the value of that cookie.

Creating ads and the group

I am not going through the process of creating and publishing ads and groups here. For this tutorial, create all your ads and put them into a single group. 

The group type of this group can be ordered or random. I recommend the ordered type with the weight in the same order as the ads’ appearance in the rotation. Like in the screenshot below.

Ad rotation with specific order
Ordered ad group with different ad weights for a specific order of ads

The ad rotation logic

Basically, the rotation logic is looking like this:

  • use the Cookie visitor condition to show the first ad when no ad was displayed before
  • use the Cookie visitor condition to deliver the following ads only if the previous ad in the rotation was displayed before
  • save the index of the current ad in a cookie using the Custom Code option

The cookie name I am using here is advads-group-last-ad. You can use any other name. Use a different name for each group if you have multiple of these rotations.

Ad #1

Based on the logic above, the first ad uses these settings.

Go down to the Visitor Conditions box and select the Cookie condition.

Since this is the first ad, we only display it if no cookie exists. The setting looks like the following screenshot.

settings for a specific order of ads
Adding a cookie condition

Now, go to the Layout / Output box and enable the Custom Code option. Add the following code into the field.

<script>advads.set_cookie('advads-group-last-ad', 1, 1);</script>

This saves the advads-group-last-ad cookie with the value 1 for one day.

Ad #2

TThe Cookie condition of ad #2 looks a bit different. This ad only shows up if the previous ad was displayed before. That means that the advads-group-last-ad cookie exists and has the value 1.

Cookie settings to create a specific order of ads
Cookie condition to ensure the specific order

The Custom Code looks similar to ad #1. We just change the index.

<script>advads.set_cookie('advads-group-last-ad', 2, 1);</script>

Ad #3 (the last ad)

No surprise with the cookie condition. We are basing this ad on the cookie set by ad #2.

Cookie settings to define a specific order of ads
Cookie condition for cookie 3

The Custom Code option for the last ad is different. To go back to ad #1, we need to remove the cookie entirely. We do this by setting the last parameter to 0.

<script>advads.set_cookie('advads-group-last-ad', 3, 0);</script>

That’s it. The ads should rotate evenly now.

Starting with a random ad

If you want to start the rotation with a random ad and then pick up the order, add another Cookie condition to all ads.

This screenshot shows an example for ad #3.

Cookie settings for a specific order of ads
Condition setup for ad rotation in a specific order with a random first ad

Subscribe to our newsletter and get 2 add-ons for free!

* indicates required
Interests

Limitations

There are a few limitations I can think of.

  • Enable Cache Busting (also included in Advanced Ads Pro) to make this work on cached websites.
  • It won’t work if the ads have additional and different visitor conditions. E.g., if ad #2 only shows on mobile, ad #3 would never show up on desktop either, and the rotation stops.
  • This method works on a per-visitor basis. E.g., every individual visitor starts with ad #1, unless you use the random setup mentioned above.
Author image Thomas

Starting in 2009, Thomas’ own word game website grew to 40 MM page impressions per month. He then built Advanced Ads to help his colleagues to place ads and test different ad positions and networks tests without any coding skills. Thomas now enjoys improving the product for our more than 150,000 users worldwide.

With over a decade of industry expertise, Advanced Ads is your surefooted ally in the ad tech realm. Their array of WordPress ad manager plugins enhances your advertising strategy, ensuring effective ad placements. Rely on their ad tech proficiency to stay ahead in the dynamic world of digital advertising. Contact info

Advanced Ads icon

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.