marcwitteveen / vwo
为在您的网站中实现Visual Website Optimizer提供简单的PHP辅助函数。
dev-master
2020-08-05 01:44 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2024-09-05 10:59:15 UTC
README
此类提供了一些简单的PHP辅助函数,用于在您的网站中实现Visual Website Optimizer。
入门
您可以通过向您的composer.json文件中的require
语句添加以下行来使用Composer安装此包。
"marcwitteveen/vwo": "dev-master"
然后从终端运行
sudo composer update
代码示例
use MarcWitteveen\Vwo\Vwo; Vwo::asynchronous("xxxxxx", true, $2000, 2500, false); /* This will render the following code: <!-- Start VWO Async Smartcode --> <script type='text/javascript'> window._vwo_code = window._vwo_code || (function(){ var account_id=xxxxxx, settings_tolerance=2000, library_tolerance=2500, use_existing_jquery=false, is_spa=1, hide_element='body', f=false,d=document,code={use_existing_jquery:function(){return use_existing_jquery;},library_tolerance:function(){return library_tolerance;},finish:function(){if(!f){f=true;var a=d.getElementById('_vis_opt_path_hides');if(a)a.parentNode.removeChild(a);}},finished:function(){return f;},load:function(a){var b=d.createElement('script');b.src=a;b.type='text/javascript';b.innerText;b.onerror=function(){_vwo_code.finish();};d.getElementsByTagName('head')[0].appendChild(b);},init:function(){ window.settings_timer=setTimeout('_vwo_code.finish()',settings_tolerance);var a=d.createElement('style'),b=hide_element?hide_element+'{opacity:0 !important;filter:alpha(opacity=0) !important;background:none !important;}':'',h=d.getElementsByTagName('head')[0];a.setAttribute('id','_vis_opt_path_hides');a.setAttribute('type','text/css');if(a.styleSheet)a.styleSheet.cssText=b;else a.appendChild(d.createTextNode(b));h.appendChild(a);this.load('https://#/j.php?a='+account_id+'&u='+encodeURIComponent(d.URL)+'&f='+(+is_spa)+'&r='+Math.random());return settings_timer; }};window._vwo_settings_timer = code.init(); return code; }()); </script> <!-- End VWO Async Smartcode --> */
方法
Vwo::asynchronous($account_id = "", $enabled = false, $settingsTolerance = 2000, $libraryTolerance = 2500, $useExistingJquery = false)
asynchronous
方法
描述
渲染一个异步JavaScript代码片段,调用需要在标签之前尽可能高地放置。
Vwo::synchronous($accountId = "", $enabled = false)
synchronous
方法
描述
渲染一个同步JavaScript代码片段,调用需要在标签之前尽可能高地放置。