Android的谷歌Analytics跟踪Android、Analytics

2023-09-06 11:16:27 作者:别拿装逼当典范 ゜

我已经设置了谷歌Analytics(分析)V2测试版上测试项目为波纹管

MainActivity.java

 公共类MainActivity延伸活动{    上下文语境;    @覆盖    保护无效的onCreate(捆绑savedInstanceState){        super.onCreate(savedInstanceState);        的setContentView(R.layout.activity_main);        上下文=这一点;        //设置语境谷歌分析        EasyTracker.getInstance()setContext(上下文)。    }    @覆盖    保护无效调用onStart(){        super.onStart();        。EasyTracker.getInstance()activityStart(本);        EasyTracker.getInstance();        跟踪myTracker = EasyTracker.getTracker();        myTracker.sendView(戒);    }    @覆盖    保护无效的onStop(){        super.onStop();        。EasyTracker.getInstance()activityStop(本);    }    @覆盖    公共布尔onCreateOptionsMenu(菜单菜单){        //充气菜单;如果是present这增加了项目操作栏。        。getMenuInflater()膨胀(R.menu.activity_main,菜单);        返回true;    }} 

analytics.xml

 <?XML版本=1.0编码=UTF-8&GT?;<资源的xmlns:工具=htt​​ps://schemas.android.com/tool​​s工具:忽略=TypographyDashes>    <! - 与您的跟踪ID替换占位符ID  - >    <字符串名称=ga_trackingId> UA和放大器;#8211;&37418075放大器;#8211; 1 LT; /串>    <! - 启用自动跟踪​​活动 - >    <布尔NAME =ga_autoActivityTracking>真< /布尔>    <! - 启用自动跟踪​​例外 - >    <布尔NAME =ga_reportUncaughtExceptions>真< /布尔>    <布尔NAME =ga_debug>真< /布尔>    <! - 将出现在您的报告中屏幕名称 - >    <字符串名称=com.m7.google_analytics_v2.BaseActivity>家庭和LT; /串>< /资源> 

我一直在尝试发送追踪谷歌分析服务器,但无法找到任何形式的命中或活动。它需要时间,以反映?

我觉得这在日志猫

  15 01-13:16:52.360:I / GAV2(23176):螺纹[GAThread,5,主]:putHit叫01-13 15:16:52.360:I / GAV2(23176):螺纹[GAThread,5,主]:发送命中存储01-13 15:16:52.440:I / GAV2(23176):螺纹[GAThread,5,主]:putHit叫01-13 15:16:52.440:I / GAV2(23176):螺纹[GAThread,5,主]:发送命中存储01-13 15:16:53.825:I / GAV2(23176):螺纹[GAThread,5,主]:putHit叫01-13 15:16:53.825:I / GAV2(23176):螺纹[GAThread,5,主]:发送命中存储01-13 15:16:53.905:I / GAV2(23176):螺纹[GAThread,5,主]:putHit叫01-13 15:16:53.905:I / GAV2(23176):螺纹[GAThread,5,主]:发送命中存储01-13 15:16:57.840:I / GAV2(23176):螺纹[GAThread,5,主]:putHit叫01-13 15:16:57.840:I / GAV2(23176):螺纹[GAThread,5,主]:发送命中存储01-13 15:16:57.945:I / GAV2(23176):螺纹[GAThread,5,主]:putHit叫01-13 15:16:57.945:I / GAV2(23176):螺纹[GAThread,5,主]:发送命中存储 
谷歌分析GA中小企业必备10大要点

解决方案

这看起来并不好:

 <字符串名称=ga_trackingId> UA和放大器;#8211;&37418075放大器;#8211; 1 LT; /串> 

&放大器;#8211; ( - )是&放大器; ndash的;这与ASCII不同的字符( - ) - (&放大器;#45 )。我是pretty确保GA只是预计的跟踪ID ASCII。

除非粘贴到堆栈溢出时刚插入。

I have set up Google Analytics v2 beta on a test project as bellow

MainActivity.java

public class MainActivity extends Activity {
    Context context;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        context = this;

        // Set Context to Google Analytics
        EasyTracker.getInstance().setContext(context);
    }

    @Override
    protected void onStart() {
        super.onStart();
        EasyTracker.getInstance().activityStart(this);

        EasyTracker.getInstance();
        Tracker myTracker = EasyTracker.getTracker();
        myTracker.sendView("harsha");
    }

    @Override
    protected void onStop() {
        super.onStop();
        EasyTracker.getInstance().activityStop(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}

analytics.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="https://schemas.android.com/tools" tools:ignore="TypographyDashes">

    <!-- Replace placeholder ID with your tracking ID -->
    <string name="ga_trackingId">UA&#8211;37418075&#8211;1</string>

    <!-- Enable automatic activity tracking -->
    <bool name="ga_autoActivityTracking">true</bool>

    <!-- Enable automatic exception tracking -->
    <bool name="ga_reportUncaughtExceptions">true</bool>
    <bool name="ga_debug">true</bool>
    <!-- The screen names that will appear in your reporting -->
    <string name="com.m7.google_analytics_v2.BaseActivity">Home</string>

</resources>

I have been trying to send the tracking to Google Analytics Server but not able to find any hits or activity of any kind. Does it take time for it to reflect ?

I find this in the Log Cat

01-13 15:16:52.360: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:52.360: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:52.440: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:52.440: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:53.825: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:53.825: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:53.905: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:53.905: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:57.840: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:57.840: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store
01-13 15:16:57.945: I/GAV2(23176): Thread[GAThread,5,main]: putHit called
01-13 15:16:57.945: I/GAV2(23176): Thread[GAThread,5,main]: Sending hit to store

解决方案

This doesn't look good:

 <string name="ga_trackingId">UA&#8211;37418075&#8211;1</string>

&#8211; (–) is &ndash; which is a different character from the ASCII - (-) (&#45). I'm pretty sure GA just expects ASCII in the tracking Id.

Unless that was just inserted when pasting into stack overflow.

 
精彩推荐
图片推荐