PluginProbe
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.13.0
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.13.0
5.13.0 5.12.1 5.12.0 5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 All 83 releases
matomo / classes / WpMatomo / WpStatistics / DataConverters / SearchEngineConverter.php
SearchEngineConverter.php
38 lines 991 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WpMatomo\WpStatistics\DataConverters;
4
5 use Piwik\DataTable;
6 use WpMatomo\WpStatistics\Importers\Actions\RecordImporter;
7
8 /**
9 * @package WpMatomo
10 * @subpackage WpStatisticsImport
11 */
12 class SearchEngineConverter extends VisitorsConverter implements DataConverterInterface {
13
14 public static function convert( array $wp_statistics_data ) {
15 $key = 'engine';
16 $data = [];
17 if ( count( $wp_statistics_data ) ) {
18 foreach ( $wp_statistics_data as $row ) {
19 if ( ! array_key_exists( $row[ $key ], $data ) ) {
20 $data[ $row[ $key ] ] = [
21 'label' => RecordImporter::get_label( $row, $key ),
22 'nb_visits' => 0,
23 'nb_uniq_visitors' => 0,
24 ];
25 }
26 $data[ $row[ $key ] ]['nb_visits'] += $row['nb'];
27 $data[ $row[ $key ] ]['nb_uniq_visitors'] += $row['nb'];
28 }
29 }
30 $datatable = new DataTable();
31 foreach ( array_values( $data ) as $row ) {
32 $datatable->addRowFromSimpleArray( $row );
33 }
34
35 return $datatable;
36 }
37 }
38