Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- (function () {
- var pageProductFormTimer = 10;
- function sendProductId() {
- var itemId = productForm = document.querySelector("#product_addtocart_form");
- var select = document.querySelector('.control>select');
- var options = {once: true};
- if (!itemId) return;
- itemId = itemId.getAttribute('data-product-sku');
- if (parseInt(itemId) && adoric)
- adoric.trigger("pageview", {
- type: "product",
- ids: itemId,
- })/*else current product has dropdown select we check listener answer */
- else if (itemId && select && adoric) {
- select.addEventListener('change', function() {
- setTimeout(function() {
- var skuSpan = document.querySelector('.simple-sku>span');
- if (!skuSpan)return;/*maybe same problem page*/
- itemId = skuSpan.textContent.split(' ')[1];
- adoric.trigger("pageview", {
- type: "product",
- ids: itemId,
- })
- }, 300)
- }, options
- );
- }
- }
- function waitPageProduct() {
- pageProductFormTimer--;
- var productForm = document.querySelector("#product_addtocart_form");
- if (!productForm && pageProductFormTimer > 0) {
- setTimeout(waitPageProduct, 1000);
- } else if (pageProductFormTimer > 0) {
- sendProductId();
- }
- }
- waitPageProduct();
- }
- )();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement