homepage Welcome to WebmasterWorld Guest from 54.226.10.234
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
onclick click action
smallcompany

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4532626 posted 9:16 pm on Jan 2, 2013 (gmt 0)

Hi,

First, Happy New Year!

I find that people use coupons from my site while not clicking through my affiliate links.
I'm trying to get the click through rate up by having a coupon hidden requiring click action to reveal it. So far I have this:

script

<script type="text/javascript">
function toggle(obj) {
var obj=document.getElementById(obj);
if (obj.style.display == "block") obj.style.display = "none";
else obj.style.display = "block";
}
</script>

HTML code

<a href="javascript: void(0);" onClick="toggle('couponcode')">Click here to get the coupon code</a>
<div id="couponcode" style="display:none;"><strong>MYCOUPON</strong></div>

Now I would like to have one more thing happen onclick which is to use a link that will drop the cookie.
Those that used to do cookie stuffing would do something like this:

<img src="http://www.example.com/" width="1" height="1" />

Now, I want to do a similar thing, but only when somebody clicks to reveal the link (otherwise, it would be against the TOS). Would that be possible with the existing example?

Thanks

 

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4532626 posted 10:29 pm on Jan 2, 2013 (gmt 0)

I guess only one click is valid, so maybe

<script type="text/javascript">
function showCoupon(el) {
el.style.display == "none"; // hide link
document.getElementById('couponcode').style.display = ''; // show coupon
document.getElementById('couponImage').src = 'http://www.example.com/'; // cookie stuff
return false; // do not follow link
}
</script>

HTML code

<a href="#" onClick="showCoupon(this)">Click here to get the coupon code</a>
<div id="couponcode" style="display:none;"><strong>MYCOUPON</strong></div>
<img id="couponImage" src="/dummy.gif" width="1" height="1"/> // use a valid image url

smallcompany

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4532626 posted 6:05 am on Jan 3, 2013 (gmt 0)

Hi,

Thanks for this.

When I tried it, I got the link reported in privacy report in IE as soon as I landed onto the page.
My goal is to see my URL being parsed only when a click onto the "reveal coupon" link happens.
I used my tracking link in both script and dummy image place.

daveVk

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4532626 posted 12:57 pm on Jan 3, 2013 (gmt 0)

I used my tracking link in both script and dummy image place.


Use something different as the dummy image link, preferably a small image or an image used somewhere else on the page. You do not want tracking link used prior to click.

smallcompany

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4532626 posted 6:35 pm on Jan 3, 2013 (gmt 0)

Thanks again. All seem to be right now.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved