PageSourceSearch

https://www.3chi.com/wp-content/plugins/3c-gtm-woocommerce/js/gtm-listeners-all-pages.js?ver=1.2

js 3chi.com collected 2026-09-25 23:50:53 UTC 2,842 bytes, 88 lines download raw bytes

1/**
2 * Event listeners for all pages.
3 */
4
5// Add to cart event - shop loop only
6
7jQuery('.products, .related-products-wrapper').on('click', '.button.add_to_cart_button.ajax_add_to_cart', function(event){
8    const atc_button = event.target;
9    const prod_name = atc_button.getAttribute('data-prod_name');
10    const prod_sku = atc_button.getAttribute('data-product_sku');
11    const prod_price = parseFloat(atc_button.getAttribute('data-prod_price'));
12
13    dataLayer.push({
14        'event': 'add_to_cart',
15        'ecommerce': {
16            'currency': 'USD',
17            'items': [{
18                'item_id': prod_sku,
19                'item_name': prod_name,
20                'price': prod_price,
21                'quantity': 1
22            }],
23            'value': prod_price
24        },
25        'twitter': {
26            'contents': [{
27                'content_id': prod_sku,
28                'content_name': prod_name,
29                'content_price': prod_price,
30                'content_type': 'product',
31                'num_items': 1
32            }],
33            'currency': 'USD',
34            'value': prod_price
35        },
36        'facebook': {
37            'content_ids': [prod_sku],
38            'content_type': 'product',
39            'content_name': prod_name,
40            'contents': [{
41                'id': prod_sku,
42                'quantity': 1
43            }],
44            'currency': 'USD',
45            'value': prod_price
46        }
47    });
48});
49
50// Remove from cart event - cart widget only
51
52jQuery('li.cart-item.has-icon.has-dropdown').on('click', 'a.remove.remove_from_cart_button', function(event){
53
54    const prod_sku = event.target.getAttribute('data-product_sku');
55    const prod_name = event.target.nextElementSibling.innerText;
56    const prod_price = parseFloat(event.target.parentNode.querySelector('span.quantity span.woocommerce-Price-amount.amount bdi').textContent.substring(1));
57    const prod_qty = parseInt(event.target.parentNode.querySelector('span.quantity').innerText);
58    
59    dataLayer.push({
60        'event': 'remove_from_cart',
61        'ecommerce': {
62            'currency': 'USD',
63            'items': [{
64                'item_id': prod_sku,
65                'item_name': prod_name,
66                'price': prod_price,
67                'quantity': prod_qty
68            }],
69            'value': prod_price * prod_qty
70        }
71    });
72});
73
74// Search event
75
76jQuery('input[type=search].search-field').on('input', function(){
77    clearTimeout(this.delay);
78    this.delay = setTimeout(function(){
79        jQuery(this).trigger('search');
80    }.bind(this), 800);
81}).on('search', function(){
82    if(this.value){
83        dataLayer.push({
84            'event': 'search',
85            'search_term': this.value
86        });
87    }
88});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.