Callbacks Documentation
Edit on
Codepen.io
Codepen.io
data-decorate-callback
A JavaScript function you may provide, which will be invoked before redirecting to checkout for the purpose of obtaining Google Analytics linker “decorations”. This function must accept a URL (string) as a parameter and return the decorated URL as a string. You must use this function If you are using Google Analytics for tracking to avoid gaps in tracking your users.
x
37
1
<!-- Configure an add button to add an item to the cart. -->
2
<button data-fsc-item-path-value="phot-io-main-app" data-fsc-action="Add, Checkout">Add to Cart</button>
3
4
5
<!--
6
DEMO SETUP
7
- Initialize the Store Builder Library
8
-->
9
<script
10
id="fsc-api"
11
src="https://sbl.onfastspring.com/sbl/1.0.2/fastspring-builder.min.js"
12
type="text/javascript"
13
data-storefront="fastspringexamples.test.onfastspring.com/popup-fastspringexamples"
14
data-decorate-callback="decorateURL">
15
</script>
16
17
<!-- Global site tag (gtag.js) - Google Analytics -->
18
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-57518103-7"></script>
19
<script>
20
window.dataLayer = window.dataLayer || [];
21
function gtag(){dataLayer.push(arguments);}
22
gtag('js', new Date());
23
gtag('config', 'UA-57518103-7');
24
</script>
25
26
<!-- Decorate callback function -->
27
<script>
28
function decorateURL(url) {
29
alert("decorate callback");
30
var linkerParam = null;
31
ga(function() {
32
var trackers = ga.getAll();
33
linkerParam = trackers[0].get('linkerParam');
34
});
35
return (linkerParam ? url + '?' + linkerParam : url);
36
}
37
</script>
1
1
1
1