【发布时间】:2019-08-15 06:26:13
【问题描述】:
我正在尝试编写我的第一个 Matomo 插件(位置提供程序),它将根据自定义维度列确定用户的位置。
到目前为止,我已经想出了这个代码:
<?php
namespace Piwik\Plugins\LocationProviderCustom\LocationProvider;
use Piwik\Plugins\UserCountry\LocationProvider;
class CountryProvider extends LocationProvider {
public function getLocation($info) {
// custom_dimension_1 should be accessible here
$location = array(
self::COUNTRY_CODE_KEY => 'us'
);
self::completeLocationResult($location);
return $location;
}
public function isWorking() {
return true;
}
public function isAvailable() {
return true;
}
public function getSupportedLocationInfo() {
return array(
self::COUNTRY_CODE_KEY => true
);
}
public function getInfo() {
return array(
'id' => 'locationProviderCustom',
'title' => 'Location Provide',
'description' => '',
'order' => 5
);
}
}
所以在 getLocation($info) 中我应该确定国家代码。 $info 只保存 IP 地址和浏览器语言。 我看到的所有位置提供程序插件都使用这两个属性之一来确定用户的国家/地区。
是否可以在 Location 提供中获取访问详细信息,尤其是自定义访问维度值?还是我应该以其他方式处理它?
谢谢
【问题讨论】:
标签: plugins matomo location-provider