Skip to content

Commit f473238

Browse files
committed
templating page call
1 parent 104a30c commit f473238

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

src/connections/spec/page.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,76 @@ Here's the payload of a typical `page` call with most [common fields](/docs/conn
2323
}
2424
```
2525

26+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/prism.min.js" integrity="sha512-UOoJElONeUNzQbbKQbjldDf9MwOHqxNz49NNJJ1d90yp+X9edsHyJoAs6O4K19CZGaIdjI5ohK+O2y5lBTW6uQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
27+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/themes/prism.css" integrity="sha512-EaMmVtm5YHQNg4u9UXGOueWP6nyUtCpKZojcE4Rqt/6ifpzzzuQVMTffvo8FVj4xDG04gIyWm1z1b7GqELl1eQ==" crossorigin="anonymous" referrerpolicy="no-referrer" />
28+
<script type="text/javascript">
29+
function showMessage(){
30+
var name = document.getElementById("name").value;
31+
var title = document.getElementById("title").value;
32+
var url = document.getElementById("url").value;
33+
var output = `{
34+
"anonymousId": "507f191e810c19729de860ea",
35+
"channel": "browser",
36+
"context": {
37+
"ip": "8.8.8.8",
38+
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36"
39+
},
40+
"integrations": {
41+
"All": true,
42+
"Mixpanel": false,
43+
"Salesforce": false
44+
},
45+
"messageId": "022bb90c-bbac-11e4-8dfc-aa07a5b093db",
46+
"name": "${name}",
47+
"properties": {
48+
"title": "${title}",
49+
"url": "${url}"
50+
},
51+
"receivedAt": "2015-02-23T22:28:55.387Z",
52+
"sentAt": "2015-02-23T22:28:55.111Z",
53+
"timestamp": "2015-02-23T22:28:55.111Z",
54+
"type": "page",
55+
"userId": "97980cfea0067",
56+
"version": "1.1"
57+
}`
58+
output_container.innerHTML = output
59+
Prism.highlightElement(output_container)
60+
}
61+
</script>
62+
<script>
63+
function showOutput() {
64+
var show = document.getElementById("output-code");
65+
if (show.style.display === "block") {
66+
show.style.display = "none";
67+
} else {
68+
show.style.display = "block";
69+
}
70+
}
71+
</script>
72+
73+
<div class="sample-code-container">
74+
<div class="form">
75+
<h3> Sample Page </h3>
76+
<p><b>See what your page call looks like</b></p>
77+
<label for="name">Name:</label>
78+
<input type="text" id="name"><br>
79+
<label for="title">Title:</label>
80+
<input type="text" id="title"><br>
81+
<label for="url">URL:</label>
82+
<input type="text" id="url"><br>
83+
<input type="submit" id="submit" onclick="showMessage(); showOutput()" value="See a sample page call">
84+
</div>
85+
86+
<div class="output">
87+
<h3>Sample Page Call</h3>
88+
<!-- <div class="output-code" id="output-code" style="display:none"> -->
89+
<pre class="language-javascript"><code class="language-javascript" id="output_container">
90+
91+
</code></pre>
92+
<!-- </div> -->
93+
</div>
94+
</div>
95+
2696
And here's the corresponding JavaScript event that would generate the above payload. If you're using Segment's JavaScript library, the page name and URL are automatically gathered and passed as properties into the event payload:
2797

2898
```js

0 commit comments

Comments
 (0)