einarso
(Einar)
April 17, 2016, 5:52pm
1
Hi,
I am using woo-commerce in wordpress. When I look at my visitor log, every product they view has 2x in front of the line. Something that indicates every product they visit is refreshed.
I installed Piwik using the “WooCommerce Piwik integration”. Any chance I am writing double to the database, and i case - how to stop/fix?
Attached is a screenshot of the error.
SteveG
(Stefan Giehl)
May 1, 2016, 9:28pm
3
Seems like a “mistake” in the tracking code. Did you have a look at the inserted tracking code in the website? Maybe _paq.push(['trackPageView']);
is called twice or something like that.
einarso
(Einar)
May 6, 2016, 9:27pm
4
This is from the class-wc-piwik.php file:
function category_view()
{
global $wp_query;
if (isset($wp_query->query_vars['product_cat']) && !empty($wp_query->query_vars['product_cat'])) {
$jsCode = sprintf("
_paq.push(['setEcommerceView',
false,
false,
'%s'
]);
_paq.push(['trackPageView']);
", urlencode($wp_query->queried_object->name));
wc_enqueue_js($jsCode);
}
}
function product_view()
{
global $product;
$jsCode = sprintf("
_paq.push(['setEcommerceView',
'%s',
'%s',
%s,
%f
]);
_paq.push(['trackPageView']);
",
$product->get_sku(),
urlencode($product->get_title()),
$this->getEncodedCategoriesByProduct($product),
$product->get_price()
);
wc_enqueue_js($jsCode);
}
Not really sure this helps… Seems like only one call for the tracking code…
einarso
(Einar)
June 4, 2016, 9:36am
5
well - I have found the following in the “/plugins/woocommerce-piwik-integration/includes” file:
function category_view()
{
global $wp_query;
if (isset($wp_query->query_vars['product_cat']) && !empty($wp_query->query_vars['product_cat'])) {
$jsCode = sprintf("
_paq.push(['setEcommerceView',
false,
false,
'%s'
]);
_paq.push(['trackPageView']);
", urlencode($wp_query->queried_object->name));
wc_enqueue_js($jsCode);
}
}
function product_view()
{
global $product;
$jsCode = sprintf("
_paq.push(['setEcommerceView',
'%s',
'%s',
%s,
%f
]);
_paq.push(['trackPageView']);
",
$product->get_sku(),
urlencode($product->get_title()),
$this->getEncodedCategoriesByProduct($product),
$product->get_price()
);
wc_enqueue_js($jsCode);
}
I have also found this code in the “/plugins/woocommerce-piwik-integration/timplates” file:
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function () {
var u = (("https:" == document.location.protocol) ? "https" : "http") + "://<?php echo esc_js($this->piwik_domain_name); ?>/";
_paq.push(["setTrackerUrl", u + "piwik.php"]);
_paq.push(["setSiteId", <?php echo esc_js($this->piwik_idsite); ?>]);
var d = document, g = d.createElement("script"), s = d.getElementsByTagName("script")[0];
g.type = "text/javascript";
g.defer = true;
g.async = true;
g.src = u + "piwik.js";
s.parentNode.insertBefore(g, s);
})();
Does this help for finding the fault?