你们中有谁成功地将Moengage集成到ReactJs中了吗?我试过了,把它放在HTMLWebpackPlugin模板的index.html的<head>标记中。
<script type="text/javascript">
(function(i,s,o,g,r,a,m,n){
i['moengage_object']=r;t={}; q = function(f){return function(){(i['moengage_q']=i['moengage_q']||[]).push({f:f,a:arguments});};};
f = ['track_event','add_user_attribute','add_first_name','add_last_name','add_email','add_mobile',
'add_user_name','add_gender','add_birthday','destroy_session','add_unique_user_id','moe_events','call_web_push','track','location_type_attribute'];
for(k in f){t[f[k]]=q(f[k]);}
a=s.createElement(o);m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m);
i['moe']=i['moe'] || function(){n=arguments[0];return t;}; a.onload=function(){if(n){i[r] = moe(n);}};
})(window,document,'script','https://cdn.moengage.com/webpush/moe_webSdk.min.latest.js','Moengage');
</script>我将moengage的配置放在一个名为‘moenge.js’的文件中。这样我就可以很容易地在其他文件中导入和使用它。
export const Moengage = moe({
app_id:"APP ID",
debug_logs: 0
});然后,我在另一个文件中使用它
import { Moengage } from '../config/moengage.js'
...
Moengage.track_event('Loan_Data', {
'loan_name': 'Example name',
'loan_type_id': 123,
})不幸的是,我的不能工作。你有没有试过在ReactJs上玩moengage?任何帮助都是最好的。谢谢
发布于 2018-09-05 14:49:31
窗口中提供了变量moe,因此将其放入配置文件中将不起作用。初始化脚本必须放在<head>标记中。
您可以根据需要通过window访问moe变量。在您的配置文件中,您可以尝试如下所示:export const Moengage = window.moe({ app_id:"APP ID", debug_logs: 0 });
PS。我在MoEngage上开发Web SDK。如有任何疑问,请随时与我们联系,网址为support@moengage.com。
https://stackoverflow.com/questions/52168433
复制相似问题