I have this tracking pixel that would usually be placed in the body of a "installed successfully" page:
<img src="" width="1" height="1" border="0" /> But instead, I'd like it to fire when someone clicks a download button. Is this possible? I’m thinking the download button could call a javascript function onClick that would hit the adclick.php page?
Thanks James
04 Answers
Try the following:
<script> function fire() { var img = document.createElement("img"); img.setAttribute("src", ""); /* set other attributes here */ document.body.appendChild(img); } </script> <button onClick="fire();">Click me</button> This isn't much of a PHP question, but at least you're tagging.
<script src="//"></script> <script type="text/javascript"> function iteration() { $.get(""); return false; } </script> <input type="button" value="Tracking Text" onclick="iteration();" /> Another possible solution, if you are using jQuery:
<script type="text/javascript"> function downloadButtonClicked() { $('<img src="" width="1" height="1" border="0" />').appendTo('body'); } </script> <a href="/download" onclick="downloadButtonClicked();">Download</a> Just create an image with
var trackingPxl = new Image(); and inside your download function set the src
trackingPxl.src = '