BrowsersConverter.php
4 years ago
DataConverterInterface.php
4 years ago
FilterConverter.php
4 years ago
NumberConverter.php
4 years ago
PagesTitleConverter.php
4 years ago
PagesUrlConverter.php
4 years ago
PlatformConverter.php
4 years ago
ReferrersConverter.php
4 years ago
SearchEngineConverter.php
4 years ago
SearchKeywordConverter.php
4 years ago
SearchQueryConverter.php
4 years ago
SubtableConverter.php
4 years ago
UserCityConverter.php
4 years ago
UserCountryConverter.php
4 years ago
UserRegionConverter.php
4 years ago
VisitorsConverter.php
4 years ago
VisitsTimeConverter.php
4 years ago
SearchQueryConverter.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WpMatomo\WpStatistics\DataConverters; |
| 4 | |
| 5 | use Piwik\DataTable; |
| 6 | |
| 7 | /** |
| 8 | * aggregate data on the number fields |
| 9 | * |
| 10 | * @package WpMatomo |
| 11 | * @subpackage WpStatisticsImport |
| 12 | */ |
| 13 | class SearchQueryConverter extends FilterConverter implements DataConverterInterface { |
| 14 | |
| 15 | public static function convert( array $wp_statistics_data ) { |
| 16 | $data = self::filter( $wp_statistics_data, '?s=', 'str_url' ); |
| 17 | foreach ( $data as $id => $url ) { |
| 18 | $matches = []; |
| 19 | if ( preg_match( '/\?s=(.+)$/', $url['str_url'], $matches ) ) { |
| 20 | $data[ $id ]['keyword'] = $matches[1]; |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | return self::aggregate_by_key( $data, 'keyword' ); |
| 25 | } |
| 26 | } |
| 27 |