-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle-apps-script.js
More file actions
99 lines (94 loc) · 2.37 KB
/
google-apps-script.js
File metadata and controls
99 lines (94 loc) · 2.37 KB
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
// ============================================
// GOOGLE APPS SCRIPT — Form Backend
// ============================================
//
// SETUP INSTRUCTIONS:
//
// 1. Create a new Google Sheet
// → Name it: "CrossBorder Electronic - Registrations"
//
// 2. In Row 1, add these headers (exact names):
// A1: Timestamp
// B1: Email
// C1: Language
// D1: Name
// E1: City
// F1: Genres
// G1: Subgenres
// H1: Format
// I1: Frequency
// J1: Price
// K1: Instagram
// L1: Skipped
// M1: UTM Source
// N1: UTM Medium
// O1: UTM Campaign
//
// 3. Go to: Extensions → Apps Script
//
// 4. Delete everything in Code.gs and paste this entire file
//
// 5. Click Deploy → New deployment
// → Type: Web app
// → Execute as: Me
// → Who has access: Anyone
// → Click Deploy
//
// 6. Copy the Web App URL
//
// 7. Paste the URL in index.html where it says:
// const GOOGLE_SCRIPT_URL = '';
//
// ============================================
function doPost(e) {
try {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var data = JSON.parse(e.postData.contents);
sheet.appendRow([
data.timestamp || new Date().toISOString(),
data.email || '',
data.language || '',
data.name || '',
data.city || '',
data.genres || '',
data.subgenres || '',
data.format || '',
data.frequency || '',
data.price || '',
data.instagram || '',
data.skipped || '',
data.source || '',
data.medium || '',
data.campaign || ''
]);
return ContentService
.createTextOutput(JSON.stringify({ status: 'ok' }))
.setMimeType(ContentService.MimeType.JSON);
} catch (error) {
return ContentService
.createTextOutput(JSON.stringify({ status: 'error', message: error.toString() }))
.setMimeType(ContentService.MimeType.JSON);
}
}
// Test function — run this manually to verify the sheet is working
function testAppend() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.appendRow([
new Date().toISOString(),
'test@example.com',
'en',
'Test User',
'Trieste',
'Techno, House',
'Hard Techno, Peak Time',
'Recurring events',
'2-3 times/month',
'€15-20',
'@testuser',
'No',
'test',
'',
''
]);
Logger.log('Test row added successfully');
}