H5弹窗SDK

集成SDK

1. 无埋点SDK

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

2. 集成H5弹窗SDK

将以下深色区内的整个JS代码复制到您所需分析页面中的<head><head>标签之间, 放置在GrowingIO无埋点集成代码的下方即可。
!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);
未压缩的代码(供参考)
// 集成代码
(function(window, document, src) {
// _vds 是 1.x版本无埋点,gio.q是2.x
// 1.x 插入队尾,2.x插入队顶
// Function.prototype.bind方法ie8 不支持
function bind(fn, obj) {
return function() {
fn.apply(obj, (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)))
}
}
var gio_q = !!window.gio ? bind(window.gio.q.unshift, window.gio.q) : bind(window._vds.push, window._vds);
var key = "growingio-sdk";
window[key] = {
pendingEvents: []
}
gio_q(['setListener', function(event) {
if (!!window[key] && !!window[key].eventMessageQueue) {
window[key].eventMessageQueue.feed(event)
} else if (window[key].pendingEvents.length <= 200) {
window[key].pendingEvents.push(event)
}
}])
var script = document.createElement("script");
var scriptTags=document.getElementsByTagName("script");
script.async=1;
script.src = ('https:' == document.location.protocol ? 'https://' : 'http://' )+ src;
var tag = scriptTags[scriptTags.length - 1];
tag.parentNode.insertBefore(script, tag);
})(window, document, "assets.giocdn.com/sdk/marketing/1.1/h5.js");
Last modified 3yr ago