Referral exclusions

Hi,

Currently we are experiencing some issues with conversion tracking from our webshop in Matomo.*

After customers have paid for their purchase, they are sent back to our thank you page. Unfortunately, Matomo then assigns the conversion to either Paypal or the clients bank-website, in stead of the original traffic source (Google/direct/social etc.).

Google Analytics has a function called: ‘Refferals exclusions list’. You can fill this list with domains you do not want conversions being assigned to.*

Is there a similar feature in Matomo?*

Hi,

Interestingly I think this isn’t a feature in Matomo even though Matomo automatically ignores visitors with a referrer that is on the list of known referrer spammer.

But I think this should be possible to do in a very short plugin. Basically listen to the following event, check if the referrer is as it shouldn’t be and then set $excluded to true to exclude that visitor:

If I got some time left and you want to, I could show you in more detail how that plugin file would look like.

If you could help out, please do!
Take your time, we are not in a hurry. Would be great to achieve this.

Thanks in advance!

Okay, a basic plugin would be the following (I didn’t test it):

<?php

namespace Piwik\Plugins\ExcludeUserAgents;

use Piwik\Common;
use Piwik\Tracker\Request;

class ExcludeUserAgents extends \Piwik\Plugin
{
    public function registerEvents() {
        return array(
            'Tracker.isExcludedVisit' => 'isExcludedUserAgent'
        );
    }

    public function isTrackerPlugin() {
        return true;
    }

    public function isExcludedUserAgent(&$excluded, Request $request) {
        $userAgent = $request->getUserAgent();
        $userAgent = Common::unsanitizeInputValue($userAgent);
        if ($userAgent == "test") {
            $excluded = true;
        }
    }
}

isTrackerPlugin is required as by default Matomo doesn’t load plugins that are not required during tracking.

Then you can replace the if with a regex or substring check that matches what you want.

To create the plugin you could first enable development mode and then use the generator as explained here: Setting Up: Develop - Matomo Analytics (formerly Piwik Analytics) - Developer Docs - v3

Thank you. I will ask our developer for help.

1 Like

Could I assign the conversion to the first referrer instead? See Piwik attributes conversions to the last seen referrer by default. How do I credit conversions to the first referrer instead? FAQ - Analytics Platform - Matomo

‘setConversionAttributionFirstReferrer’ does not solve the problem because the conversion for returning visitors is assigned to the referral source from the first visit, right?

Would you recommend the multi channel conversion attribution plugin?

Best regards

But if this does exclude the visit then it sure excludes also conversion data?

(I haven’t tested the code either :slight_smile: )

We should have the data (page views, conversions etc) but the conversion should be attributed to a campaign, not to the payment gateway. I’ve been thinking about solving this with cookies…