-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.php
245 lines (214 loc) · 7.1 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
/**
* Copyright (C) 2010 Webdigi UK ([email protected])
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
?>
<html>
<head>
<title>Google Analytics on Facebook</title>
<style type="text/css">
form {
width:500px;
border:1px solid #ccc;
}
fieldset {
border:0;
padding:10px;
margin:10px;
position:relative;
}
label {
display:block;
font:normal 12px/17px verdana;
}
input {width:160px;}
span.hint {
font:normal 11px/14px verdana;
background:#eee url(bg-span-hint-gray.gif) no-repeat top left;
color:#444;
border:1px solid #888;
padding:5px 5px 5px 40px;
width:250px;
position:absolute;
margin: -12px 0 0 14px;
display:none;
}
fieldset.welldone span.hint {
background:#9fd680 url(bg-span-hint-welldone.jpg) no-repeat top left;
border-color:#749e5c;
color:#000;
}
fieldset.kindagood span.hint {
background:#ffffcc url(bg-span-hint-kindagood.jpg) no-repeat top left;
border-color:#cc9933;
}
fieldset.welldone {
background:transparent url(bg-fieldset-welldone.gif) no-repeat 194px 19px;
}
fieldset.kindagood {
background:transparent url(bg-fieldset-kindagood.gif) no-repeat 194px 19px;
}
</style>
<script>
function generatecode()
{
var googleCode=escape(document.getElementById("gacode").value);
var googleDomain=escape(document.getElementById("gadomain").value);
var pageLink=escape(document.getElementById("fbpage").value);
var pageTitle=escape(document.getElementById("fbtitle").value);
var imgLink ="http://"+window.location.hostname+window.location.pathname+"fbga.php?googlecode="+googleCode+"&googledomain="+googleDomain+"&pagelink="+pageLink+"&pagetitle="+pageTitle;
document.getElementById("code").innerHTML="<label>Simply paste this code to the bottom of the page you generated this for.</label><br><textarea name='textarea' cols='60' rows='3'><img src=\'"+imgLink+"\'></img></textarea>";
}
// This function checks if the gadomain field
// is at least 5 characters long.
// If so, it attaches class="welldone" to the
// containing fieldset.
function checkGADomainForLength(whatYouTyped) {
var fieldset = whatYouTyped.parentNode;
var txt = whatYouTyped.value;
if (txt.length > 4) {
fieldset.className = "welldone";
}
else {
fieldset.className = "";
}
}
// This function checks if the fbpage field
// is at least 3 characters long.
// If so, it attaches class="welldone" to the
// containing fieldset.
function checkFBPageForLength(whatYouTyped) {
var fieldset = whatYouTyped.parentNode;
var txt = whatYouTyped.value;
if (txt.length > 2) {
fieldset.className = "welldone";
}
else {
fieldset.className = "";
}
}
// This function checks if the fbtitle field
// is at least 3 characters long.
// If so, it attaches class="welldone" to the
// containing fieldset.
function checkFBTitleForLength(whatYouTyped) {
var fieldset = whatYouTyped.parentNode;
var txt = whatYouTyped.value;
if (txt.length > 2) {
fieldset.className = "welldone";
}
else {
fieldset.className = "";
}
}
// This function checks the ga code to be sure
// it follows a certain pattern:
// UA-1231231-1
// If so, it assigns class="welldone" to the containing
// fieldset.
function checkGACode(whatYouTyped) {
var fieldset = whatYouTyped.parentNode;
var txt = whatYouTyped.value;
if (/^UA-.*-.+$/.test(txt)) {
fieldset.className = "welldone";
} else {
fieldset.className = "";
}
}
// This function checks the email address to be sure
// it follows a certain pattern:
// If so, it assigns class="welldone" to the containing
// fieldset.
function checkEmail(whatYouTyped) {
var fieldset = whatYouTyped.parentNode;
var txt = whatYouTyped.value;
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(txt)) {
fieldset.className = "welldone";
} else {
fieldset.className = "";
}
}
// this part is for the form field hints to display
// only on the condition that the text input has focus.
// otherwise, it stays hidden.
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
oldonload();
func();
}
}
}
function prepareInputsForHints() {
var inputs = document.getElementsByTagName("input");
for (var i=0; i<inputs.length; i++){
if(inputs[i].type != "button"){
inputs[i].onfocus = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
}
inputs[i].onblur = function () {
this.parentNode.getElementsByTagName("span")[0].style.display = "none";
}
}
}
}
addLoadEvent(prepareInputsForHints);
</script>
</head>
<body>
<label for="gacode"><a href="http://www.webdigi.co.uk/blog/2010/google-analytics-for-facebook-fan-pages/">Google Analytics for Facebook fan page</a>
<label for="gacode">Form below helps you generate html IMG tag code needed for EACH page you wish to track</label>
<form action="#" name="basicform" id="basicform" >
<fieldset>
<label for="gacode">Analytics Code: </label>
<input type="text" name="gacode" id="gacode" onkeyup="checkGACode(this);"></input>
<span class="hint">You get this code from Google Analytics, the code looks
like UA-1231231-1</span>
</fieldset>
<fieldset>
<label for="gadomain">Domain on Analytics:</label>
<input type="text" name="gadomain" id="gadomain" value="facebook.com" onkeyup="checkGADomainForLength(this);"></input>
<span class="hint">This is domain that you created the website profile and received the
tracking code on analytics, Mostly facebook.com</span>
</fieldset>
<fieldset>
<label for="fbpage">Page Link: </label>
<input type="text" name="fbpage" id="fbpage" onkeyup="checkFBPageForLength(this);"></input>
<span class="hint">This is to
identify the fan page when you see it on analytics. Use /contact_form,
/landing_page, etc</span>
</fieldset>
<fieldset>
<label for="fbtitle">Page Title: </label>
<input type="text" name="fbtitle" id="fbtitle" onkeyup="checkFBTitleForLength(this);"></input>
<span class="hint">This is a short description of the page title for your reference. eg:
Contact Form, Landing Page, etc</span>
</fieldset>
<fieldset>
<input type="button" onclick="generatecode();" value="Generate Code"></input>
</fieldset>
</form>
<br/>
<div id="code">Click on Generate Code above</div>
<br>
Brought to you by a <a href="http://www.webdigi.co.uk">Web Development Company in London</a>
</body>
</html>