function piwiktracking_javascript_tracking() { $piwik_url = esc_attr(piwiktracking_get_option('piwikurl')); $site_id = esc_attr(piwiktracking_get_option('siteid')); if (!$piwik_url && !$site_id) { return; } $linktracking = piwiktracking_get_option('linktracking') ? '_paq.push(["enableLinkTracking"]);' . "\n" : ''; $subdomaintracking = piwiktracking_get_option('subdomaintracking') ? '_paq.push(["setCookieDomain", "*.' . piwiktracking_get_domain() . '"]);' . "\n" : ''; $prependsitedomain = piwiktracking_get_option('prependsitedomain') ? '_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);' . "\n" : ''; $hidealiasclicks = piwiktracking_get_option('hidealiasclicks') ? '_paq.push(["setDomains", ["*.' . piwiktracking_get_domain() . '"]]);' . "\n" : ''; $cliensidednt = piwiktracking_get_option('clientsidednt') ? '_paq.push(["setDoNotTrack", true]);' . "\n" : ''; ?> <!-- Piwik --> <script type="text/javascript"> var _paq = _paq || []; <?php echo $prependsitedomain; ?> <?php echo $subdomaintracking; ?> <?php echo $hidealiasclicks; ?> <?php echo $cliensidednt; ?> _paq.push(["trackPageView"]); <?php echo $linktracking; ?> (function() { var u = (("https:" == document.location.protocol) ? "https" : "http") + "://" + "<?php echo $piwik_url; ?> "; _paq.push(["setTrackerUrl", u + "piwik.php"]); _paq.push(["setSiteId", "<?php echo $site_id; ?> "]); 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); })(); </script> <!-- End Piwik Code --> <?php }
function piwiktracking_section_basic() { global $piwiktracking; $html = '<div id="piwiktracking-settings-basic" class="piwiktracking-section">' . "\n"; $html .= '<h3>' . __('Piwiktracking Basic Settings', 'piwiktracking') . '</h3>' . "\n"; $html .= piwiktracking_create_setting(array('id' => 'piwikurl', 'type' => 'text', 'class' => 'regular-text', 'label' => __('Piwik Base URL', 'piwiktracking'), 'desc' => __('the base URL to your Piwik installation (without http(s)://)', 'piwiktracking'))); $html .= piwiktracking_create_setting(array('id' => 'siteid', 'type' => 'text', 'class' => 'small-text', 'label' => __('Your Piwik SiteID', 'piwiktracking'))); $html .= piwiktracking_create_setting(array('id' => 'linktracking', 'type' => 'checkbox', 'value' => true, 'label' => __('Enable outlink & downloads tracking', 'piwiktracking'))); $html .= piwiktracking_create_setting(array('id' => 'subdomaintracking', 'type' => 'checkbox', 'value' => true, 'label' => __('Track visitors across all subdomains of ' . piwiktracking_get_domain(), 'piwiktracking'))); $html .= piwiktracking_create_setting(array('id' => 'prependsitedomain', 'type' => 'checkbox', 'value' => true, 'label' => __('Prepend the site domain to the page title when tracking', 'piwiktracking'))); $html .= piwiktracking_create_setting(array('id' => 'hidealiasclicks', 'type' => 'checkbox', 'value' => true, 'label' => __('In the "Outlinks" report, hide clicks to known alias URLs', 'piwiktracking'))); $html .= piwiktracking_create_setting(array('id' => 'clientsidednt', 'type' => 'checkbox', 'value' => true, 'label' => __('Enable client side DoNotTrack detection', 'piwiktracking'))); $html .= '</div>' . "\n"; echo $html; }