PageSourceSearch

https://www.springerpub.com/static/version1789146322/frontend/Spri…/Meta_Conversion/js/customizeProduct.js

js springerpub.com collected 2026-09-24 08:47:42 UTC 3,474 bytes, 87 lines download raw bytes

1define([
2    'jquery',
3    'Meta_Conversion/js/metaPixelTracker'
4], function ($, metaPixelTracker) {
5    'use strict';
6
7    let productName, sku, productId, price, payload;
8
9    return function (config) {
10
11        function callMetaPixelTracker() {
12            if (config !== null) {
13                // browser event payload
14                config.browserEventData.payload.content_name = payload.productName;
15                config.browserEventData.payload.content_ids = [payload.sku];
16                config.browserEventData.payload.content_type = 'product_group';
17
18                // server event payload
19                config.payload.content_name = payload.productName;
20                config.payload.content_ids = [payload.sku];
21                config.payload.content_type = 'product_group';
22
23                metaPixelTracker(config);
24            }
25        }
26
27        function _getPrice(element) {
28            // For Swatch and Text Type - PLP page
29            productId = $(element).parents('.product-item-details').find('.price-final_price').data('product-id');
30            // for DropdownType, Swatch and Text Type - PDP page
31            if (!productId) {
32                productId = $(element).parents('.product-info-main').find('.price-final_price').data('product-id');
33            }
34            price = $('#product-price-' + productId).data('price-amount');
35            if (!price) {
36                // get product price based on the catalog price display type (including/excluding tax)
37                price = $('#price-excluding-tax-product-price-' + productId).data('price-amount');
38            }
39            // Guard against undefined price when neither selector resolves a value
40            return price ? parseFloat(price).toFixed(2) : '0.00';
41        }
42
43        function _getProductName(element) {
44            // For Swatch and Text Type - PLP page
45            productName = $(element).parents('.product-item-details').find('.product-item-link').text();
46            productName = productName.trim();
47            // for DropdownType, Swatch and Text Type - PDP page
48            if (!productName) {
49                productName = $(element).parents('.product-info-main').find('.page-title .base').text();
50                productName = productName.trim();
51            }
52            return productName;
53        }
54
55        function _getSku(element) {
56            // For Swatch and Text Type - PLP page
57            sku = $(element).parents('li.product-item').find('form').data('product-sku');
58            // for Swatch and Text Type - PDP page
59            if (!sku) {
60                sku = $(element).parents('.product-info-main').find('.product.attribute.sku .value').text();
61                sku = sku.trim();
62            }
63            return sku;
64        }
65
66        function setPayload(element) {
67            payload = {
68                'productName': _getProductName(element),
69                'sku': _getSku(element)
70            };
71            config.browserEventData.payload.value = _getPrice(element);
72            config.payload.value = _getPrice(element);
73        }
74
75        // Dropdown event for pdp
76        $('.super-attribute-select').on('change', function () {
77            setPayload(this);
78            callMetaPixelTracker();
79        });
80
81        // swatch click event from everywhere
82        $('[class*="swatch-opt"]').on('click', '.swatch-option', function () {
83            setPayload(this);
84            callMetaPixelTracker();
85        });
86    };
87});

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.