Double Tracking with Custom Tags

Hi, I’m trying to use Matomo to specifically track users wich get custom generated Mails with Custom Generated Links.
The Links look somewhat like:
URL/Module_Language_Type.html?UPN=UPN from Database

I’ve created a custom Tag configuration so that the UPN is tracked as the UserID.

Since I don’t want to show a cookie Banner I enabled cookieless Tracking.

I’ve embedded the Matomo Tracking script and the Matomo Tag manager in the Website like this:

!DOCTYPE html>
<html lang="de">
<head>
    <script src="./assets/ValidateGet.js"></script>
    <!-- Matomo Tag Manager -->
    <script src="./assets/Matomo_tagmanager.js"></script>
    <!-- End Matomo Tag Manager -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./assets/awareness.css">
    <!-- Matomo -->
        <script src="./assets/Matomo_tracking.js"></script>
    <!-- End Matomo Code -->
</head>

the js files look like this:

Matomo_tagmanger.js

var _mtm = window._mtm = window._mtm || [];
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src='https://awareness.bucs-it.de/analytics/js/container_Wufbx124.js'; s.parentNode.insertBefore(g,s);

Matomo_tracking.js

var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(["disableCookies"]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
  var u="//awareness.bucs-it.de/analytics/";
  _paq.push(['setTrackerUrl', u+'matomo.php']);
  _paq.push(['setSiteId', '1']);
  var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
  g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();

The tracking itself works. The problem is, that I’m getting duplicate entries in Matomo.
Everytime its once with the custom UPN as UserID and once without the custom UPN.

Has anyone any Idea why this happens?
I’ve tried embedding the scripts directly into the Website but this doesn’t work either.

Since I cant embed more then one Screenshot I will append them in the comments.

UPN as UserID in Matomo Tag Manager
image

UPN Variable in Matomo Tag Manager:

Tracking Event with custom UPN as UserID:

Tracking Event without custom UPN:

image

Hi @crankbrother
I would suggest 2 things:

  1. Don’t bootstrap with MTM and PAQ. Just choose the one you want. As you use the Tag manager, just use _mtm. If not you will track twice.
  2. If you want to track the visit origin, I think that campaign are more designed for this. See link below.

Hi Philipe,
this seemst to be it!
I was not ware that the MTM does also track :man_facepalming:t2:

1 Like