javascript - Adding pixel tracking to a link -
i had marketing company send me bunch of 1x1 pixel tracking images add page. these work fine, no issues.
they wanted 1 of trackers added link goes out page, problem is.
heres example of pixel tracker: (actual link removed)
<img class="fmfjfemzqkmxnkeezyst" width="1" height="1" src="//insight.adsrvr.org/track/conv/123" alt="" style="border-style:none;">
how can add link needs fire when clicked? initial thought add "src" straight "a tag" looking back, doesn't make sense.
you can append image dom renders on click of link, while preventing default until after tracker appends:
$("a#imgtracker").click(function (e) { e.preventdefault(); $("body").append('<img class="fmfjfemzqkmxnkeezyst" width="1" height="1" src="//insight.adsrvr.org/track/conv/123" alt="" style="border-style:none;">'); location.href = $(this).attr("href"); //or hardcode url here });
Comments
Post a Comment