@@ -52,7 +52,7 @@ However, if you are installing the script on a subdomain (e.g. **app.example.com
52
52
53
53
``` html Other
54
54
<script
55
- src =" https://cdn.dub.co /analytics.js"
55
+ src =" https://www.dubcdn.com /analytics/script .js"
56
56
data-cookie-options =' {"domain": ".example.com"}'
57
57
/>
58
58
` ` `
@@ -74,13 +74,80 @@ By default, the script sets the `dub_id` cookie to expire in 90 days. You can cu
74
74
75
75
` ` ` html Other
76
76
< script
77
- src= " https://cdn.dub.co /analytics.js"
77
+ src= " https://www.dubcdn.com /analytics/script .js"
78
78
data- cookie- options= ' {"expiresInDays": 60}'
79
79
/ >
80
80
` ` `
81
81
82
82
</CodeGroup>
83
83
84
+ ### Load the script via a reverse proxy
85
+
86
+ To avoid ad-blockers from blocking the ` @dub/ analytics` script, it is recommended to use a reverse proxy.
87
+
88
+ Depending on which backend framework you're using, there are a few different ways to do this:
89
+
90
+ <CodeGroup>
91
+
92
+ ` ` ` javascript Next .js
93
+ // next.config.js
94
+ module .exports = {
95
+ async rewrites () {
96
+ return [
97
+ {
98
+ source: " /_proxy/dub/script.js" ,
99
+ destination: " https://www.dubcdn.com/analytics/script.js" ,
100
+ },
101
+ ];
102
+ },
103
+ };
104
+ ` ` `
105
+
106
+ ` ` ` json Vercel
107
+ // vercel.json
108
+ {
109
+ " rewrites" : [
110
+ {
111
+ " source" : " /_proxy/dub/script.js" ,
112
+ " destination" : " https://www.dubcdn.com/analytics/script.js"
113
+ }
114
+ ]
115
+ }
116
+ ` ` `
117
+
118
+ </CodeGroup>
119
+
120
+ Once you've set up your reverse proxy, don't forget to update the ` scriptProps .src ` parameter in the ` < Analytics / > ` component to point to your proxy URL.
121
+
122
+ <CodeGroup>
123
+
124
+ ` ` ` typescript React/ Next .js
125
+ import { Analytics as DubAnalytics } from " @dub/analytics/react" ;
126
+
127
+ export default function App () {
128
+ return (
129
+ < Layout>
130
+ < DubAnalytics
131
+ scriptProps= {{
132
+ src: " /_proxy/dub/script.js" , // pointing to your reverse proxy
133
+ }}
134
+ / >
135
+ {/* Your app code here */ }
136
+ < / Layout>
137
+ );
138
+ }
139
+ ` ` `
140
+
141
+ ` ` ` javascript Other Frameworks
142
+ // include this script tag in your HTML Head tag
143
+ < script
144
+ src= " /_proxy/dub/script.js" // pointing to your reverse proxy
145
+ defer
146
+ / >
147
+ ` ` `
148
+
149
+ </CodeGroup>
150
+
84
151
## Open-source examples
85
152
86
153
Here are some open-source code examples that you can referece:
0 commit comments