Google Analytics正确报告我的Android应用引发的异常.我可以使用预定电子邮件将此报告发送给我.但是,在没有任何要报告的情况下收到每日电子邮件(即,报告告诉我发生了零例外)是单调乏味的.因此,我希望仅在有报告内容时才接收电子邮件(即报告告诉我发生了一个或多个异常).似乎自定义警报可用于此目的.但是,自定义警报似乎与例外不兼容.这引出了我的问题.
可以将自定义警报配置为提供有关例外的电子邮件通知吗?
或者,更一般地说,
是否可以将Google Analytics配置为提供有关例外的电子邮件通知?
此外,这也适用于崩溃吗?
更新(2015年11月22日,2015年12月1日)
(部分)回答.我提供了一个答案,可以将服务器(而不是Google Analytics)配置为提供有关异常的电子邮件通知,这可能是许多人的充分解决方案.
(几乎是)答案.jakub-kriz已经提供了详细的答案,但它没有按原样运作.在答案的基础上,我能够在没有异常发生时将Google Analytics配置为电子邮件.这与要求完全相反.不幸的是,当发生一个或多个异常时,我无法收到电子邮件.
替代方向.jakub-kriz提出了一种替代解决方案,即使用正常事件而不是异常事件.我没有尝试过这个方向.
尚未提出完整的解决方案.
Jak*_*riz 10
这是可能的,但不是直接的,你必须把你的分析弄得很脏.
在管理 - >视图 - >过滤器 - >自定义 - >高级中创建两个过滤器
创建侦听hitType异常的过滤器并设置事件类别 - 异常
创建过滤器,将异常描述复制到事件操作中
在管理 - >视图 - >目标 - >自定义 - >事件中创建两个过滤器
事件类别等于异常
目标包含异常的自定义警报
不要忘记你的电子邮件
试试这个让我知道!
可以将服务器(不是 Google Analytics)配置为提供有关异常的电子邮件通知,这对于许多人来说可能是一个足够的解决方案。
首先,您需要一个服务帐户,可以创建该帐户https://console.developers.google.com/project/_/apiui/credential。您将创建一个密钥文件 ( MyAnalytics.p12)。
其次,我们配置分析客户端 ( MyAnalytics.php):
<?php
//You'll need to install google-api-php-client
//(https://github.com/google/google-api-php-client)
require_once 'Google/autoload.php';
class MyAnalytics
{
//When logged into Google Analytics you'll have a URL that looks
//something like https://www.google.com/analytics/web/?authuser=0#home/a00w11p22/
//Your profile id is everything after the p
const PROFILE_ID = '22';
//This is the service account email that you constructed in step 1
const SERVICE_ACCOUNT_EMAIL = 'blah@developer.gserviceaccount.com';
//This is the file that you constructed in step 1.
const KEY_FILE_LOCATION = 'MyAnalytics.p12';
private $client;
private $analytics;
private $cred;
public function __construct() {
$this->client = new Google_Client();
$this->analytics = new Google_Service_Analytics($this->client);
$key = file_get_contents(self::KEY_FILE_LOCATION);
$this->cred = new Google_Auth_AssertionCredentials(
self::SERVICE_ACCOUNT_EMAIL,
array(Google_Service_Analytics::ANALYTICS_READONLY),
$key
);
}
public function getAnalytics() {
$this->client->setAssertionCredentials($this->cred);
if($this->client->getAuth()->isAccessTokenExpired()) {
$this->client->getAuth()->refreshTokenWithAssertion($this->cred);
}
return $this->analytics;
}
}
?>
Run Code Online (Sandbox Code Playgroud)
第三,我们查询并报告异常情况(exceptions.php):
<?php
require_once 'MyAnalytics.php';
$myAnalytics = new MyAnalytics();
$analytics = $myAnalytics->getAnalytics();
$results = $analytics->data_ga->get(
'ga:' . MyAnalytics::PROFILE_ID,
'yesterday',
'today',
'ga:exceptions'
);
$a = $results->getTotalsForAllResults();
$count = $a['ga:exceptions'];
echo $count;
if (is_numeric($count) && $count > 0) {
//handle the exception, e.g., send an email
//(cf. /sf/answers/373471801/)
}
?>
Run Code Online (Sandbox Code Playgroud)
第四,配置 cron 来运行exceptions.php(参见/sf/answers/1565125061/)。
| 归档时间: |
|
| 查看次数: |
1247 次 |
| 最近记录: |