|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Add notification when the number of total sessions is less than the previous 30 days. |
|
5
|
|
|
* Recurrence: 30 Days |
|
6
|
|
|
* |
|
7
|
|
|
* @since 7.12.3 |
|
8
|
|
|
*/ |
|
9
|
|
|
final class MonsterInsights_Notification_Traffic_Dropping extends MonsterInsights_Notification_Event { |
|
10
|
|
|
|
|
11
|
|
|
public $notification_id = 'monsterinsights_notification_traffic_dropping'; |
|
12
|
|
|
public $notification_interval = 30; // in days |
|
13
|
|
|
public $notification_type = array( 'basic', 'lite', 'master', 'plus', 'pro' ); |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Build Notification |
|
17
|
|
|
* |
|
18
|
|
|
* @return array $notification notification is ready to add |
|
19
|
|
|
* |
|
20
|
|
|
* @since 7.12.3 |
|
21
|
|
|
*/ |
|
22
|
|
|
public function prepare_notification_data( $notification ) { |
|
23
|
|
|
$data = array(); |
|
24
|
|
|
$report = $this->get_report(); |
|
25
|
|
|
$data['prev_sessions_difference'] = isset( $report['data']['infobox']['sessions']['prev'] ) ? $report['data']['infobox']['sessions']['prev'] : 0; |
|
26
|
|
|
|
|
27
|
|
|
if ( ! empty( $data ) && $data['prev_sessions_difference'] < 0 ) { |
|
28
|
|
|
$notification['title'] = __( 'Your Website Traffic Is Dropping', 'google-analytics-for-wordpress' ); |
|
29
|
|
|
// Translators: Traffic dropping notification content |
|
30
|
|
|
$notification['content'] = sprintf( __( 'Your website traffic is decreasing and that’s a reason to take action now. Less traffic means less opportunities to make your brand known, make relationships and ultimately sell your service or product. <br><br>Follow the marketing hacks of %sthis article%s to start growing your traffic again.', 'google-analytics-for-wordpress' ), '<a href="'. $this->build_external_link( 'https://www.monsterinsights.com/marketing-hacks-guaranteed-to-grow-your-traffic/' ) .'" target="_blank">', '</a>' ); |
|
31
|
|
|
$notification['btns'] = array( |
|
32
|
|
|
"learn_more" => array( |
|
33
|
|
|
'url' => $this->build_external_link( 'https://www.monsterinsights.com/marketing-hacks-guaranteed-to-grow-your-traffic/' ), |
|
34
|
|
|
'text' => __( 'Learn More', 'google-analytics-for-wordpress' ) |
|
35
|
|
|
), |
|
36
|
|
|
"view_report" => array( |
|
37
|
|
|
'url' => $this->get_view_url(), |
|
38
|
|
|
'text' => __( 'View Report', 'google-analytics-for-wordpress' ) |
|
39
|
|
|
), |
|
40
|
|
|
); |
|
41
|
|
|
|
|
42
|
|
|
return $notification; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
return false; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
// initialize the class |
|
51
|
|
|
new MonsterInsights_Notification_Traffic_Dropping(); |
|
52
|
|
|
|