/
facebook-remarketing.liquid
32 lines (29 loc) · 1.02 KB
/
facebook-remarketing.liquid
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
<!-- Custom Facebook Variant Remarketing Code -->
{% comment %}
Include this file at the bottom of your product page template.
{% endcomment %}
<script type="text/javascript">
$( document ).ready(function() {
if( fbq ) {
fbq("track", "ViewContent", {
content_name: "{{ product.title }}",
content_category: "{{ product.type }}",
value: {{ product.price | money_without_currency | remove: ',' }},
currency: "{{ shop.currency }}",
content_ids: [{{ product.selected_or_first_available_variant.id }}],
content_type: "product"
});
// Attache add to cart event
$( "#AddToCart" ).click(function() {
fbq("track", "AddToCart", {
content_name: "{{ product.title }}",
content_category: "{{ product.type }}",
value: {{ product.price | money_without_currency | remove: ',' }},
currency: "{{ shop.currency }}",
content_ids: [{{ product.selected_or_first_available_variant.id }}],
content_type: "product"
});
});
}
});
</script>