H5弹窗SDK

集成SDK

1. 无埋点SDK

H5弹窗SDK会自动去识别Web无埋点的版本进行兼容,所以Web无埋点1.x和2.x均可集成H5弹窗SDK。

2. 集成H5弹窗SDK

将以下深色区内的整个JS代码复制到您所需分析页面中的<head><head>标签之间, 放置在GrowingIO无埋点集成代码的下方即可。
1
!function(n,e){function t(e,n){return function(){e.apply(n,1===arguments.length?[arguments[0]]:Array.apply(null,arguments))}}var s=n.gio?t(n.gio.q.unshift,n.gio.q):t(n._vds.push,n._vds),i="growingio-sdk";n[i]={pendingEvents:[]},s(["setListener",function(e){n[i]&&n[i].eventMessageQueue?n[i].eventMessageQueue.feed(e):n[i].pendingEvents.length<=200&&n[i].pendingEvents.push(e)}]);var o=e.createElement("script"),r=e.getElementsByTagName("script");o.async=1,o.src=("https:"==e.location.protocol?"https://":"http://")+"assets.giocdn.com/sdk/marketing/1.1/h5.js";var g=r[r.length-1];g.parentNode.insertBefore(o,g)}(window,document);
Copied!
未压缩的代码(供参考)
1
// 集成代码
2
(function(window, document, src) {
3
// _vds 是 1.x版本无埋点,gio.q是2.x
4
// 1.x 插入队尾,2.x插入队顶
5
// Function.prototype.bind方法ie8 不支持
6
function bind(fn, obj) {
7
return function() {
8
fn.apply(obj, (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)))
9
}
10
}
11
var gio_q = !!window.gio ? bind(window.gio.q.unshift, window.gio.q) : bind(window._vds.push, window._vds);
12
var key = "growingio-sdk";
13
window[key] = {
14
pendingEvents: []
15
}
16
gio_q(['setListener', function(event) {
17
if (!!window[key] && !!window[key].eventMessageQueue) {
18
window[key].eventMessageQueue.feed(event)
19
} else if (window[key].pendingEvents.length <= 200) {
20
window[key].pendingEvents.push(event)
21
}
22
}])
23
24
25
var script = document.createElement("script");
26
var scriptTags=document.getElementsByTagName("script");
27
script.async=1;
28
script.src = ('https:' == document.location.protocol ? 'https://' : 'http://' )+ src;
29
var tag = scriptTags[scriptTags.length - 1];
30
tag.parentNode.insertBefore(script, tag);
31
})(window, document, "assets.giocdn.com/sdk/marketing/1.1/h5.js");
Copied!
Last modified 2yr ago