1
+ <?php
2
+
3
+ /**
4
+ * Generic Server-Side Google Analytics PHP Client
5
+ *
6
+ * This library is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU Lesser General Public
8
+ * License (LGPL) as published by the Free Software Foundation; either
9
+ * version 3 of the License, or (at your option) any later version.
10
+ *
11
+ * This library is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ * Lesser General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU Lesser General Public
17
+ * License along with this library; if not, write to the Free Software
18
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19
+ *
20
+ * Google Analytics is a registered trademark of Google Inc.
21
+ *
22
+ * @link http://code.google.com/p/php-ga
23
+ *
24
+ * @license http://www.gnu.org/licenses/lgpl.html
25
+ * @author Thomas Bachem <tb@unitedprototype.com>
26
+ * @copyright Copyright (c) 2010 United Prototype GmbH (http://unitedprototype.com)
27
+ */
28
+
29
+ namespace UnitedPrototype \GoogleAnalytics ;
30
+
31
+ class SocialInteraction {
32
+
33
+ /**
34
+ * Required. A string representing the social network being tracked (e.g. "Facebook", "Twitter", "LinkedIn", ...),
35
+ * will be mapped to "utmsn" parameter
36
+ *
37
+ * @see Internals\ParameterHolder::$utmsn
38
+ * @var string
39
+ */
40
+ protected $ network ;
41
+
42
+ /**
43
+ * Required. A string representing the social action being tracked (e.g. "Like", "Share", "Tweet", ...),
44
+ * will be mapped to "utmsa" parameter
45
+ *
46
+ * @see Internals\ParameterHolder::$utmsa
47
+ * @var string
48
+ */
49
+ protected $ action ;
50
+
51
+ /**
52
+ * Optional. A string representing the URL (or resource) which receives the action. For example,
53
+ * if a user clicks the Like button on a page on a site, the the target might be set to the title
54
+ * of the page, or an ID used to identify the page in a content management system. In many cases,
55
+ * the page you Like is the same page you are on. So if this parameter is not given, we will default
56
+ * to using the path of the corresponding Page object.
57
+ *
58
+ * @see Internals\ParameterHolder::$utmsid
59
+ * @var string
60
+ */
61
+ protected $ target ;
62
+
63
+
64
+ /**
65
+ * @param string $path
66
+ */
67
+ public function __construct ($ network = null , $ action = null , $ target = null ) {
68
+ if ($ network !== null ) $ this ->setNetwork ($ network );
69
+ if ($ action !== null ) $ this ->setAction ($ action );
70
+ if ($ target !== null ) $ this ->setTarget ($ target );
71
+ }
72
+
73
+ public function validate () {
74
+ if ($ this ->network === null || $ this ->action === null ) {
75
+ Tracker::_raiseError ('Social interactions need to have at least the "network" and "action" attributes defined. ' , __METHOD__ );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * @param string $network
81
+ */
82
+ public function setNetwork ($ network ) {
83
+ $ this ->network = $ network ;
84
+ }
85
+
86
+ /**
87
+ * @return string
88
+ */
89
+ public function getNetwork () {
90
+ return $ this ->network ;
91
+ }
92
+
93
+ /**
94
+ * @param string $action
95
+ */
96
+ public function setAction ($ action ) {
97
+ $ this ->action = $ action ;
98
+ }
99
+
100
+ /**
101
+ * @return string
102
+ */
103
+ public function getAction () {
104
+ return $ this ->action ;
105
+ }
106
+
107
+ /**
108
+ * @param string $target
109
+ */
110
+ public function setTarget ($ target ) {
111
+ $ this ->target = $ target ;
112
+ }
113
+
114
+ /**
115
+ * @return string
116
+ */
117
+ public function getTarget () {
118
+ return $ this ->target ;
119
+ }
120
+
121
+ }
122
+
123
+ ?>
0 commit comments