Page 1 of 1

amazon ad suck

Posted: Mon Sep 26, 2016 3:52 pm
by Vegan
amazon ads are good in some ways suck in others

https://hardcoregames.azurewebsites.net/?page_id=31924

has over 100 compact disks in a store page

so wordpress sucks even more with <iframe> so I am wondering if I should consider some additional code to select a max of 20 CDs for an ad box to eventually be stuffed into a widget

amazon uses javascript which is not that hard to work with, but i was wondering how to leverage resources, now that i have a database server to work with

the goal is to grab 20 unique CDs from a swarm of over 100 and then conjure up a amazon native ad that will work

Code: Select all

<script type="text/javascript">
amzn_assoc_placement = "adunit0";
amzn_assoc_search_bar = "true";
amzn_assoc_tracking_id = "************";
amzn_assoc_ad_mode = "manual";
amzn_assoc_ad_type = "smart";
amzn_assoc_marketplace = "amazon";
amzn_assoc_random_permute = "true";
amzn_assoc_rows = "4";
amzn_assoc_region = "US";
amzn_assoc_title = "";
amzn_assoc_linkid = "0d6c8c027673600081f274c6a3abe7f9";
amzn_assoc_asins = "B00004WF5I,B00IN69QEY,B00000I8LG,B00000JMKF,B00ILAWJFU,B00004WF5H,B00000K1I5,B000066EZQ,B003X0NNM6,B000066F2I,B00004YLPU,B00004WF7B,B0000457II,B00000I8LO,B00004U0OV,B00003002J,B000WE4CK8,B00000JT6E,B00000I8LM,B00000I8LH";
</script>
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US"></script>
I was figuring using a JavaScript switch() but that is maybe too crude. I have code to randomize so I can turn off the amazon randomizer if I wanted. Seems if I simply shuffle and select 20 is the best strategy I can think of.

Code: Select all

// Fisher-Yates shuffle model
function shuffle(array) {
  	var m = array.length, t, i;
   	while (m) { // While there remain elements to shuffle ...
	    i = Math.floor(Math.random() * m--); // Pick a remaining element ...
	    t = array[m]; // And swap it with the current element...
	    array[m] = array[i];
	    array[i] = t;
	  }
  	return array;
}
found a swap that might be leveragable

Code: Select all

Array.prototype.swap = function (x,y) {
  var b = this[x];
  this[x] = this[y];
  this[y] = b;
  return this;
}
So I guess any JS array can manage, say swarm() and then append with the data

then pick the first 20 with each page load

Re: amazon ad suck

Posted: Sat Oct 01, 2016 9:34 am
by Vegan
the problem I see, amzn_assoc_asins = is simply one big fat string, so the host server has to do some string processing too


so this boils down to using an array and converting it to a string format