Tracking Code Help


#1

I recently took over Piwik Management for my company. I updated Piwik on our servers and am trying to push out the new tracking code.

This is what I have: Doesn’t seem to be tracking users. Any help would be greatly appreciated.

Thanks-

Ian



<!-- Begin Piwik Tracking Code -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(["trackPageView"]);
  _paq.push(["enableLinkTracking"]);
  _paq.push(['setCookieDomain', '*.childbirthinjuries.com']);
  _paq.push(['setCustomVariable', 1, 'ConvertroID',$CVO.getCode(),'visit']);

  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.d50media.com/piwik/";
    _paq.push(["setTrackerUrl", u+"piwik.php"]);
    _paq.push(["setSiteId", "5"]);
    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 Tracking Code -->



#2

Does it work if you remove the code:
_paq.push([‘setCustomVariable’, 1, ‘ConvertroID’,$CVO.getCode(),‘visit’]); If so, then you might need to work on that piece of code.

Also, the only thing I wonder about is the “setSiteId”, “5” Is this really the correct siteID? If you just set this up, I think the siteID would be “1” or maybe "2 "or “3” if you had created DEV sites first.


#3

Hey Dianna-

Thanks for the response. Yes, the site ID is 5. We actually have over 200 different sites we use Piwik on, I just picked site 5 as it gets the least amount of traffic. We hadn’t updated Piwik in over 1.5 years, so this is the new tracking code Piwik provided when I selected “get tracking code”

I added:


 _paq.push(['setCookieDomain', '*.childbirthinjuries.com']);
  _paq.push(['setCustomVariable', 1, 'ConvertroID',$CVO.getCode(),'visit']);

You are most likely right that I need to work on that section.

I am also trying to use this in Google Tag Manager, as we have so many sites. My thinking is that it should still track, maybe just not pull in the custom variable. Thoughts?

Thanks-

Ian


#4

Hi Ian. I would remove the lines for custom variables completely, and then see if tracking begins. I think it will.


#5

Dianna-

You are right- It is working now! Thanks!

I will work on the custom variable.

Thanks again!

Ian


#6

You are very welcome! It’s nice to be able to help someone. I use this Forum often when I encounter problems, and I am always grateful to those who try to help.


(Matthieu Aubry) #7

Put some quotes around the value: $CVO.getCode()


#8

Thanks everyone- I removed the setcookie domain and CVO and it worked-


<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(["trackPageView"]);
  _paq.push(["enableLinkTracking"]);

  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.d50media.com/piwik/";
    _paq.push(["setTrackerUrl", u+"piwik.php"]);
    _paq.push(["setSiteId", "5"]);
    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 -->

Matt- are you saying to do this?


<!-- Piwik -->
<script type="text/javascript">
  var _paq = _paq || [];
  _paq.push(["trackPageView"]);
  _paq.push(["enableLinkTracking"]);
 _paq.push(['setCustomVariable', 1, 'ConvertroID',"$CVO.getCode()",'visit']);
  (function() {
    var u=(("https:" == document.location.protocol) ? "https" : "http") + "://piwik.d50media.com/piwik/";
    _paq.push(["setTrackerUrl", u+"piwik.php"]);
    _paq.push(["setSiteId", "5"]);
    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 -->


#9

Wrapping the php code in php tags would work. Give it a try…


_paq.push(['setCustomVariable', 1, 'ConvertroID', '<?php echo $CVO.getCode(); ?>','visit']);