Good day…
Odd thing has been happening on my site with my desired functionality.
- We send email from platform with urls
- Urls go thru redirect link that has script that will append an ID value.
- User redirected to landing page where Matomo Custom Dimension code installed.
- Here is the odd part. When I test it, I can track as expected, but when actual email recipients click thru on url in the body of the email, they aren’t being tracked. I can tell this because we have another email click tracking mechanism in place.
- Any thoughts/suggestions as to what’s happening and/or how/where I could go to troubleshoot would be greatly appreciated.
- Sample tracking link that would be included in email message:
- Sample code on my landing page:
<script type="text/javascript">
function $_GET(param) {
var vars = {};
window.location.href.replace( location.hash, '' ).replace(
/[?&]+([^=&]+)=?([^&]*)?/gi, // regexp
function( m, key, value ) { // callback
vars[key] = value !== undefined ? value : '';
}
);
if ( param ) {
return vars[param] ? vars[param] : null;
}
return vars;
}
var prospect_id = $_GET('ref_id');
if(prospect_id){
var _paq = window._paq || [];
/ tracker methods like "setCustomDimension" should be called before "trackPageView" /
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//getsimpledata.com/analytics/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
_paq.push(['trackPageView', window.title, {dimension1: prospect_id}]);
}else{
var _paq = window._paq || [];
/ tracker methods like "setCustomDimension" should be called before "trackPageView" /
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//getsimpledata.com/analytics/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
}
</script>