Skip to content

Commit 3303f0d

Browse files
authored
Merge pull request pytorch#443 from shiftlab/track-downloads
Wire up FB Pixel and Google Analytics event tracking
2 parents c6143b7 + afa4fa5 commit 3303f0d

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

_templates/layout.html

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,73 @@
1212
ga('send', 'pageview');
1313

1414
</script>
15+
16+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-117752657-2"></script>
17+
18+
<script>
19+
20+
window.dataLayer = window.dataLayer || [];
21+
22+
function gtag(){dataLayer.push(arguments);}
23+
24+
gtag('js', new Date());
25+
gtag('config', 'UA-117752657-2');
26+
27+
</script>
28+
29+
<script>
30+
!function(f,b,e,v,n,t,s)
31+
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
32+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
33+
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
34+
n.queue=[];t=b.createElement(e);t.async=!0;
35+
t.src=v;s=b.getElementsByTagName(e)[0];
36+
s.parentNode.insertBefore(t,s)}(window,document,'script',
37+
'https://connect.facebook.net/en_US/fbevents.js');
38+
fbq('init', '243028289693773');
39+
fbq('track', 'PageView');
40+
41+
$("a.reference.download").on('click', function(){
42+
fbq('trackCustom', "Download", {
43+
tutorialTitle: $('h1:first').text(),
44+
downloadLink: this.href,
45+
tutorialLink: window.location.href,
46+
downloadTitle: this.innerText
47+
});
48+
ga('send', {
49+
hitType: 'event',
50+
eventCategory: 'Download',
51+
eventAction: 'click',
52+
eventLabel: this.innerText
53+
});
54+
});
55+
56+
$("[data-behavior='was-this-helpful-event']").on('click', function(){
57+
$(".helpful-question").hide();
58+
$(".was-helpful-thank-you").show();
59+
fbq('trackCustom', "Was this Helpful?", {
60+
tutorialLink: window.location.href,
61+
tutorialTitle: $('h1:first').text(),
62+
helpful: $(this).attr("data-response")
63+
});
64+
ga('send', {
65+
hitType: 'event',
66+
eventCategory: 'Was this Helpful?',
67+
eventAction: 'click',
68+
eventLabel: $(this).attr("data-response")
69+
});
70+
});
71+
72+
if (location.pathname == "/") {
73+
$(".helpful-container").hide();
74+
$(".hr-bottom").hide();
75+
}
76+
</script>
77+
78+
<noscript>
79+
<img height="1" width="1"
80+
src="https://www.facebook.com/tr?id=243028289693773&ev=PageView
81+
&noscript=1"/>
82+
</noscript>
1583
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&amp;guid=ON&amp;script=0"/>
1684
{% endblock %}

0 commit comments

Comments
 (0)