I have seen this come up in suggestions before
"Can I apply a discount code from a link"?
Also, it's important, if you use discount codes, that you have a discounts page on your website. This serves several purposes.
Lots of coupon websites will harvest your codes and publish them. They send traffic to your site, and this is good, but they are promoting your competitors and harvesting old, no longer valid, codes.
Customers will also use a search engine to search for your company name - discounts or coupons. (ex - acme.com coupon codes)
It would much preferred to have your own discount codes page that shows current active codes and other savings you offer customers.
This page should eventually show better in the SE's than the other coupon codes sites.
Take control of your discount code destiny todayStep 1 (if you don't already have a discounts page)
Clone one of your pages and change the name of the page to something like websitename-discount-coupon-codes.asp
This needs to have all of the standard ect include lines, so you should clone a store page, products.asp for example.
Change the page title and meta description and clear the content area and create your new content.
You might like to list some codes that are currently active and have links to those products there.
Step 2
It would be great if visitors could actually type in a code right there, and not need to write it down and enter it during checkout.
Here we insert the javascript and .asp code that will duplicate the (checkout) coupon function on the page.
In the content area of the page, where you want the coupon input box to appear, add this
Take note there of the space where you will want to enter your URL of the page where you have placed this code. This is critical if you want to use step three (optional) and it causes no harm if you do not use step three.
<script type="text/javascript">
function applycertcallback(){
if(ajaxobj.readyState==4){
var retvals=ajaxobj.responseText.split('&');
alert(retvals[1]);
if(retvals[0]=='success'){document.getElementById("cpncode").value='';window.location.href = 'the-name-of-your-page-here.asp';}
}
}
function applycert(){
var cpncode=document.getElementById("cpncode").value;
if(cpncode!=""){
ajaxobj=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("MSXML2.XMLHTTP");
ajaxobj.onreadystatechange=applycertcallback;
ajaxobj.open("GET", "vsadmin/ajaxservice.asp?action=applycert&stg1=1&cpncode="+cpncode, true);
ajaxobj.send(null);
}
}
function removecert(cpncode){
if(cpncode!=''){
ajaxobj=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject("MSXML2.XMLHTTP");
ajaxobj.onreadystatechange=applycertcallback;
ajaxobj.open("GET", "vsadmin/ajaxservice.asp?action=applycert&stg1=1&act=delete&cpncode="+cpncode, true);
ajaxobj.send(null);
}
}
</script>
<%
print "<div class=""cartcoupon_cntnr"">"
print "<div class=""cartcoupontext"">" & labeltxt(xxGifNum,"cpncode") & "</div>"
cpnarr=split(trim(SESSION("giftcerts")), " ")
for index=0 to UBOUND(cpnarr)
print "<div class=""cartcouponapplied"">" & imageorlink("",xxRemove&" : "&cpnarr(index),"applycoupon removecoupon1","removecert('"&cpnarr(index)&"')",TRUE) & "</div>"
next
cpnarr=split(trim(SESSION("cpncode")), " ")
for index=0 to UBOUND(cpnarr)
print "<div class=""cartcouponapplied"">" & imageorlink("",xxRemove&" : "&cpnarr(index),"applycoupon removecoupon1","removecert('"&cpnarr(index)&"')",TRUE) & "</div>"
next
print "<div class=""cartcoupon""><input type=""text"" name=""cpncode"" id=""cpncode"" size=""" & IIfVr(mobilebrowser,13,18) & """ style=""font-size:11px"" autocomplete=""off"" /> " & imageorbutton(imgapplycoupon,xxApply,"applycoupon applycoupon1","applycert()",TRUE) & "</div>"
print "</div>"
%>
Again, take note there of the space where you will want to enter your URL of the page where you have placed this code. This is critical if you want to use step three (optional) and it causes no harm if you do not use step three.Step 3
Wouldn't it be really great to send a code in a link that would apply itself?
Have no fear....
Think of the possibilities, you can create these links in your email promos.
Visitors will not make a purchase and call to say "I forgot to apply my code from the email, can I still get my discount"
I you want to email a customer a special discount code, you can just say, "click this link to apply your code"
Make a social media post with a code without actually having to say what the code is.. Just click the link to activate the code.
At the bottom of the page, just before the closing </body> tag, add the following code
<!-- begin coupon code populate -->
<% if request.querystring("action")<>"" then %>
<script type="text/javascript">
function getQueryString() {
var qs = document.location.search,pairs,pair,key,value,el,i,n;
if (qs.length > 0) {
qs = qs.substr(1);
pairs = qs.split(/&/);
for (i = 0, n = pairs.length; i < n; i++) {
pair = pairs[i].split(/=/);
key = pair[0];
value = decodeURIComponent(pair[1].replace(/\+/g, " "));
el = document.getElementById(key);
if (el) {
el.value = value;
}
}
pairs = null;
pair = null;
el = null;
}
}
window.addEventListener('load',getQueryString,false);
window.addEventListener('load',applycert,false);
if(window.attachEvent){
window.attachEvent('onload',getQueryString);
window.attachEvent('onload',applycert);
}
</script>
<% end if %>
<!-- end coupon code populate -->
Step 4 (only if you opted into step 3

)
Create your URL that will populate your code on that page.
www.yoursite.com/websitename-discount-coupon-codes.asp
?action=applycert&cpncode=YOURCOUPONCODEThe part in red there is the querystring and you want it entered exactly as it is here, with the exception of your desired code there at the end in place of
YOURCOUPONCODEDavid
ECT Power User
