Skip to content

Commit 6d41481

Browse files
committed
integration docs
1 parent f0f9d06 commit 6d41481

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

docs/integration.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Integration Instructions
2+
3+
To integrate V-Analytics with your website, follow these steps:
4+
5+
## Step 1: Include the Integration Code
6+
7+
Place the following JavaScript code within your website's HTML to start sending analytics data:
8+
9+
```html
10+
<script>
11+
document.addEventListener('DOMContentLoaded', (event) => {
12+
// API endpoint URL
13+
const siteKey = 'YOUR_SITE_KEY_HERE'; // Replace with your site's key
14+
const apiUrl = `http(s)://<HOST_URL>/analytics/sites/${siteKey}`;
15+
16+
// Data to send to the API
17+
const data = {
18+
visitorData: event,
19+
siteData: window.location
20+
};
21+
22+
// Options for the fetch request
23+
const options = {
24+
method: 'POST',
25+
headers: {
26+
'Content-Type': 'application/json',
27+
},
28+
body: JSON.stringify(data),
29+
};
30+
31+
// Make the API request
32+
fetch(apiUrl, options)
33+
.then(response => {
34+
if (response.ok) {
35+
console.log('API request succeeded');
36+
} else {
37+
error('API request failed');
38+
}
39+
})
40+
.catch(error => {
41+
console.error('Error:', error);
42+
});
43+
});
44+
</script>
45+
46+
```
47+
## STEP 2 - Replace 'YOUR_SITE_KEY_HERE'
48+
49+
**Replace 'YOUR_SITE_KEY_HERE' in the code with your actual site's key. This key is provided to you by V-Analytics.**
50+
51+
## Step 3: Include the Code in Your Website
52+
**Add the provided code snippet to all the pages of your website where you want to track visitor analytics.**
53+
54+
## Step 4: Verify Integration
55+
56+
**Open your website in a browser and check your browser's console for the following messages:**
57+
58+
"API request succeeded" (if the request is successful).
59+
"API request failed" (if there's an issue with the request).
60+
61+
If you see "API request succeeded," your integration is successful, and your website is now sending analytics data to V-Analytics.
62+
63+
If you encounter issues, please refer to the V-Analytics documentation or contact our support for assistance.**

0 commit comments

Comments
 (0)