Skip to content

Commit 3c1af49

Browse files
hasittyaga001
authored andcommitted
Add segment script and update iframe attributes for YouTube video player (#68)
1 parent e5e33a0 commit 3c1af49

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

docusaurus.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ const config: Config = {
164164
"https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js",
165165
"/docs/js/code-block-buttons.js",
166166
"https://cdnjs.cloudflare.com/ajax/libs/axios/1.2.1/axios.min.js",
167+
{
168+
src: "/js/segment.js",
169+
async: false,
170+
},
167171
{
168172
src: "https://js.hs-scripts.com/43613284.js",
169173
type: "text/javascript",

static/js/segment.js

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
!(function () {
2+
var i = "analytics",
3+
analytics = (window[i] = window[i] || []);
4+
if (!analytics.initialize)
5+
if (analytics.invoked)
6+
window.console &&
7+
console.error &&
8+
console.error("Segment snippet included twice.");
9+
else {
10+
analytics.invoked = !0;
11+
analytics.methods = [
12+
"trackSubmit",
13+
"trackClick",
14+
"trackLink",
15+
"trackForm",
16+
"pageview",
17+
"identify",
18+
"reset",
19+
"group",
20+
"track",
21+
"ready",
22+
"alias",
23+
"debug",
24+
"page",
25+
"screen",
26+
"once",
27+
"off",
28+
"on",
29+
"addSourceMiddleware",
30+
"addIntegrationMiddleware",
31+
"setAnonymousId",
32+
"addDestinationMiddleware",
33+
"register",
34+
];
35+
analytics.factory = function (e) {
36+
return function () {
37+
if (window[i].initialized)
38+
return window[i][e].apply(window[i], arguments);
39+
var n = Array.prototype.slice.call(arguments);
40+
if (
41+
["track", "screen", "alias", "group", "page", "identify"].indexOf(
42+
e
43+
) > -1
44+
) {
45+
var c = document.querySelector("link[rel='canonical']");
46+
n.push({
47+
__t: "bpc",
48+
c: (c && c.getAttribute("href")) || void 0,
49+
p: location.pathname,
50+
u: location.href,
51+
s: location.search,
52+
t: document.title,
53+
r: document.referrer,
54+
});
55+
}
56+
n.unshift(e);
57+
analytics.push(n);
58+
return analytics;
59+
};
60+
};
61+
for (var n = 0; n < analytics.methods.length; n++) {
62+
var key = analytics.methods[n];
63+
analytics[key] = analytics.factory(key);
64+
}
65+
analytics.load = function (key, n) {
66+
var t = document.createElement("script");
67+
t.type = "text/javascript";
68+
t.async = !0;
69+
t.setAttribute("data-global-segment-analytics-key", i);
70+
t.src =
71+
"https://cdn.segment.com/analytics.js/v1/" +
72+
key +
73+
"/analytics.min.js";
74+
var r = document.getElementsByTagName("script")[0];
75+
r.parentNode.insertBefore(t, r);
76+
analytics._loadOptions = n;
77+
};
78+
analytics._writeKey = "IvcQvqtKQS24hYl0lkuvsfFSCpCse4F8";
79+
analytics.SNIPPET_VERSION = "5.2.0";
80+
analytics.load("IvcQvqtKQS24hYl0lkuvsfFSCpCse4F8");
81+
analytics.page();
82+
}
83+
})();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy