Answers.Body: <p>I built a plugin which does exactly this... <strong><a href="https://www.doublesecretagency.com/plugins/ad-wizard" rel="nofollow noreferrer">Ad Wizard</a></strong>.</p>
  
  <p>You can put your ads into groups, and add that group to your template like this:</p>
  
  <pre><code>{{ craft.adWizard.position('rightSidebar') }}
  </code></pre>
  
  <p>That code will automatically display a random ad from the group (unless it's disabled, expired, or over its maximum allowed impressions).</p>
  
  <p>You can also target a single ad specifically, by referring to its ID number:</p>
  
  <pre><code>{{ craft.adWizard.ad(42) }}
  </code></pre>
  
  <p>The plugin also gives you built in ad tracking... You can add <a href="https://www.doublesecretagency.com/plugins/ad-wizard/docs/seeing-your-ad-statistics" rel="nofollow noreferrer">two chart widgets</a> to your dashboard which will show you statistics on how your ads are doing.</p>
  
  <p>If you need any help, feel free to contact support@doublesecretagency.com... All feedback, bug reports, and feature requests are welcome!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T05:09:31.077Z
Answers.Text: Great! Feel free to contact me with any feedback or issues. :)
Answers.UserDisplayName: Lindsey D
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2014-08-18T02:17:21.450Z
Answers.LastActivityDate: 2019-04-01T17:30:34.163Z
Answers.LastEditDate: 2019-04-01T17:30:34.163Z
Answers.UserDisplayName: Lindsey D
Answers.Body: <p>You build this in a couple different ways but the simplest would be to setup ads as as channel with an asset for the add, url etc. In the template you could set the ad [the entry] to appear randomly by using shuffle().</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T05:10:55.097Z
Answers.Text: Ahh, awesome: [shuffle()](http://buildwithcraft.com/docs/templating/functions#shuffle). Thanks Adam!
Answers.UserDisplayName: Hafa
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2014-08-18T00:42:52.760Z
Answers.LastActivityDate: 2019-04-01T17:28:47.167Z
Answers.LastEditDate: 2019-04-01T17:28:47.167Z
Answers.UserDisplayName: Adam McCombs
Body: <p>What would be the best way to build an Ad rotator similar to those we usually see around from <a href="http://fusionads.net">http://fusionads.net</a> for example.</p>
  
  <p>WordPress have a plugin/widget for adding ads: <a href="https://wordpress.org/plugins/ad-rotator/">https://wordpress.org/plugins/ad-rotator/</a></p>
  
  <p>Basically it shows random HTML code every time you refresh the page. </p>
  
  <p>I was wondering how we can do that with Craft.</p>
  
Tags: <templating><best-practice>
Title: What would be the best way to build an Ad rotator?
ThreadText: # What would be the best way to build an Ad rotator?
  
  (Asked by: username_0 on 2014-08-18)
  
  What would be the best way to build an Ad rotator similar to those we usually see around from <http://fusionads.net> for example.
  
  WordPress have a plugin/widget for adding ads: <https://wordpress.org/plugins/ad-rotator/>
  
  Basically it shows random HTML code every time you refresh the page.
  
  I was wondering how we can do that with Craft.
  
  **Tags:** templating, best-practice
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2014-08-18. Score: 4
  
  I built a plugin which does exactly this... **[Ad Wizard](https://www.doublesecretagency.com/plugins/ad-wizard)**.
  
  You can put your ads into groups, and add that group to your template like this:
  
  ```
  {{ craft.adWizard.position('rightSidebar') }}
  
  ```
  
  That code will automatically display a random ad from the group (unless it's disabled, expired, or over its maximum allowed impressions).
  
  You can also target a single ad specifically, by referring to its ID number:
  
  ```
  {{ craft.adWizard.ad(42) }}
  
  ```
  
  The plugin also gives you built in ad tracking... You can add [two chart widgets](https://www.doublesecretagency.com/plugins/ad-wizard/docs/seeing-your-ad-statistics) to your dashboard which will show you statistics on how your ads are doing.
  
  If you need any help, feel free to contact support@doublesecretagency.com... All feedback, bug reports, and feature requests are welcome!
  
  > **Comments:**
  > **username_1**: Great! Feel free to contact me with any feedback or issues. :)  
  
  ---
  
  ### Answer by username_2 on 2014-08-18. Score: 3
  
  You build this in a couple different ways but the simplest would be to setup ads as as channel with an asset for the add, url etc. In the template you could set the ad [the entry] to appear randomly by using shuffle().
  
  > **Comments:**
  > **username_0**: Ahh, awesome: [shuffle()](http://buildwithcraft.com/docs/templating/functions#shuffle). Thanks username_2!  
  
  ---
  
  