Add 3rd-party pixel tracking

This commit is contained in:
zeantsoi
2015-03-25 11:40:15 -07:00
parent c61b51e4e4
commit 3724417c0f
6 changed files with 39 additions and 8 deletions

View File

@@ -672,6 +672,7 @@ class PromoteApiController(ApiController):
media_autoplay=VBoolean("media_autoplay"),
media_override=VBoolean("media-override"),
domain_override=VLength("domain", 100),
third_party_tracking=VUrl("third_party_tracking"),
is_managed=VBoolean("is_managed"),
thumbnail_file=VUploadLength('file', 500*1024),
)
@@ -679,12 +680,13 @@ class PromoteApiController(ApiController):
selftext, kind, disable_comments, sendreplies,
media_url, media_autoplay, media_override,
gifts_embed_url, media_url_type, domain_override,
is_managed, thumbnail_file):
third_party_tracking, is_managed, thumbnail_file):
return self._edit_promo(form, jquery, username, title, url,
selftext, kind, disable_comments, sendreplies,
media_url, media_autoplay, media_override,
gifts_embed_url, media_url_type, domain_override,
is_managed, thumbnail_file=thumbnail_file)
third_party_tracking, is_managed,
thumbnail_file=thumbnail_file)
@validatedForm(
VSponsor('link_id36'),
@@ -708,6 +710,7 @@ class PromoteApiController(ApiController):
media_autoplay=VBoolean("media_autoplay"),
media_override=VBoolean("media-override"),
domain_override=VLength("domain", 100),
third_party_tracking=VUrl("third_party_tracking"),
is_managed=VBoolean("is_managed"),
l=VLink('link_id36'),
)
@@ -715,18 +718,19 @@ class PromoteApiController(ApiController):
selftext, kind, disable_comments, sendreplies,
media_url, media_autoplay, media_override,
gifts_embed_url, media_url_type, domain_override,
is_managed, l):
third_party_tracking, is_managed, l):
return self._edit_promo(form, jquery, username, title, url,
selftext, kind, disable_comments, sendreplies,
media_url, media_autoplay, media_override,
gifts_embed_url, media_url_type, domain_override,
is_managed, l=l)
third_party_tracking, is_managed, l=l)
def _edit_promo(self, form, jquery, username, title, url,
selftext, kind, disable_comments, sendreplies,
media_url, media_autoplay, media_override,
gifts_embed_url, media_url_type, domain_override,
is_managed, l=None, thumbnail_file=None):
third_party_tracking, is_managed, l=None,
thumbnail_file=None):
should_ratelimit = False
if not c.user_is_sponsor:
should_ratelimit = True
@@ -788,9 +792,10 @@ class PromoteApiController(ApiController):
l = promote.new_promotion(title, url if kind == 'link' else 'self',
selftext if kind == 'self' else '',
user, request.ip)
l.domain_override = domain_override or None
if c.user_is_sponsor:
l.managed_promo = is_managed
l.domain_override = domain_override or None
l.third_party_tracking = third_party_tracking or None
l._commit()
# only set the thumbnail when creating a link
@@ -912,6 +917,7 @@ class PromoteApiController(ApiController):
if c.user_is_sponsor:
l.media_override = media_override
l.domain_override = domain_override or None
l.third_party_tracking = third_party_tracking or None
l.managed_promo = is_managed
l._commit()

View File

@@ -196,6 +196,9 @@ def add_trackers(items, sr):
"r": random.randint(0, 2147483647), # cachebuster
}
item.imp_pixel = update_query(g.adtracker_url, pixel_query)
if item.third_party_tracking:
item.third_party_tracking_url = item.third_party_tracking
# construct the click redirect url
url = urllib.unquote(item.url.encode("utf-8"))

View File

@@ -93,6 +93,7 @@ class Link(Thing, Printable):
gifts_embed_url=None,
media_autoplay=False,
domain_override=None,
third_party_tracking=None,
promoted=None,
payment_flagged_reason="",
fraud=None,

View File

@@ -165,6 +165,12 @@ r.analytics = {
pixel.src = impPixel;
}
var thirdPartyTrackingUrl = $el.data('thirdPartyTrackingUrl');
if (thirdPartyTrackingUrl) {
var thirdPartyTrackingImage = new Image();
thirdPartyTrackingImage.src = thirdPartyTrackingUrl;
}
var adServerPixel = new Image();
var adServerImpPixel = $el.data('adserverImpPixel');
var adServerClickUrl = $el.data('adserverClickUrl');

View File

@@ -132,6 +132,10 @@ ${self.RenderPrintable()}
% if hasattr(what, 'adserver_click_url'):
data-adserver-click-url="${what.adserver_click_url}"
% endif
% if hasattr(what, 'third_party_tracking_url'):
data-third-party-tracking-url="${what.third_party_tracking_url}"
% endif
</%def>
<%def name="RenderPrintable()">

View File

@@ -128,11 +128,22 @@
%else:
class="rounded" placeholder="optional"
%endif
/>
>
<div class="infotext rounded">
<p>${_("Choose a different domain name to display on the site (the small grey text next to a link)")}</p>
</div>
<label style="display:block; text-align:right" for="third_party_tracking">${_("Impression tracking URL:")}</label>
<input id="third_party_tracking" name="third_party_tracking" type="text"
%if link and link.third_party_tracking:
value="${link.third_party_tracking}" class="rounded"
%else:
class="rounded" placeholder="optional"
%endif
>
<div class="infotext rounded">
<p>${_("Enter a URL to insert into a 3rd-party impression tracking code snippet")}</p>
</div>
%endif
</%utils:line_field>
</%def>