matomo-org / matomo

Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
https://matomo.org/
GNU General Public License v3.0
19.6k stars 2.62k forks source link

Matomo Attribution Model Issue #21020

Open jorgeuos opened 1 year ago

jorgeuos commented 1 year ago

Hi DevTeam!

I have gathered some questions and thoughts about the Matomo Attribution Model. I have tried to explain it as best as I can, but I’m not sure if I’m correct. So please correct me if I’m wrong.

First we have the questions from a client, then I have added my thoughts and findings below the Results headline.

From client:  

MATOMO ATTRIBUTION RULES

 

  1. Visits are last touch https://matomo.org/faq/troubleshooting/faq_50/

    Higher “Direct Entry” visits in Matomo When tracking the acquisition source of visitors, Google Analytics stores and uses campaign data for up to 6 months and attributes subsequent direct entry visits to the original campaign acquisition source. (So Google Analytics will report a higher number of visits attributed to “Campaigns” because these visits used a campaign in the previous 6 months.) Whereas Matomo tracks any new “Direct Entry” visits as direct entries and does not attribute these new “Direct Entry” visits to their original acquisition source. With Matomo’s Multi Channel Conversion Attribution plugin, you can apply different attribution models to your goal conversions.  

  2. Conversions are last non-direct touch https://matomo.org/faq/general/what-is-the-default-attribution-model-used-in-matomo/

Data that support/ contradicts these rules

 

  1. Our Direct visits data is significantly higher than GA. All data that we have supports that this rule is correct
  2. Our conversion data does NOT support this

What we can see is that:

Why? How?

In the Matomo reporting interface:

Having examined the contents of these respective files, specifically looking for fields related to campaign activity, I can observe the following:  

What I assume is happening is:

Re-cap:

Our aim is to get:

A potential solution would be to extend the contents of the _pk_ref cookie to include these parameters and write them to either the Referrers.getReferrerType data set (or a new data set) then subsequently update the respective MarketingCampaignsReporting.* data sets to refer to this data.

Tasks

  1. Conduct a set-through analysis of the Matomo SQL queries to confirm/ deny #A1 and #A2
  2. Propose & build a solution that meets our aim

Results

After thorough analysis of the SQL queries, I have come to the following conclusions:

A1

These queries are very complex and hard to fully understand if one isn’t familiar with the datasets. And it’s too soon for me to assess if it’s supposed to be like this, if the reports are correct or not. It could be related to configuration, as I’ve learned reading the code now, there is that configConversionAttributionFirstReferrer setting for an example.

In the file called customer-journey.sql

I reproduced the steps we did together.

  1. I enter the site from a campaign URL.
  2. I browse around.
  3. I delete the _ses Cookie and close the tab.
  4. I enter directly to the site and finish an order, which should convert.

And I can see in the last query that it attributes to my campaign. Which is the correct behavior, right? Last non direct touch.

A2

The MarketingCampaignsReporting plugin uses the logs, but the logs are updated with the referral data. So it should be the same behavior. But that doesn’t exclude the possibility of the query(ies) to be wrongly formatted. What I mean is that the referrer data is the same, it is there. But for some reason, it is not respecting the last non touch approach.

Conclusion:

We need Matomos Core Team to help us to fully understand which report is correct and how we can get the data we need.

Could it be that the campaign info is missing from the inserts in: https://github.com/matomo-org/matomo/blob/115527353a9e75e01aa4d263408956ae45403bea/plugins/Referrers/Archiver.php#L61

queries.zip

michalkleiner commented 1 year ago

Hi @jorgeuos, thank you for opening such an elaborate and descriptive issue, I see you gave it a lot of thought and time and did as much investigation yourself as you could.

However, we don't provide support through the issue tracker, so unless we can clearly establish a hypothesis that a certain replicable behaviour is a bug, and provide replication steps, we can't go on too much investigating this ourselves as it could be related to configuration, reports setup, goals setup etc.

Could you perhaps try and formulate what you think is the issue in one or two sentences? We'd appreciate that! And, once again, we do appreciate a detailed report and your time put into it.

michalkleiner commented 1 year ago

@sgiehl any insights welcome here, thanks!

jorgeuos commented 1 year ago

So we have an update.

I'm short on time right now, so I will probably update this issue tomorrow. But Basically our findings have resulted in that, when a user visits the site, they get a visitorId and browses around the site. This visit is attributed to a campaign or a whatever referrer it gets. At a later point when that same user visits the site again, as a direct visit, and logs in to make a purchase, they get assigned a userId. Now in theory, the same visit should be now treated with the userId as describe here: https://matomo.org/faq/general/how-are-requests-with-a-user-id-tracked/

When a User Logs In During a Visit

When a visitor connects to your website but is not initially logged in, their visit is associated with a Visitor ID by default. This is a unique identifier for that specific visit that is not attributed to a specific user. However, once that user logs into their account and you set a User ID for this visitor, then all actions such as page views are linked to the User ID and not the visitor ID. Any previously tracked action for this visitor before the user was logged in is also associated with this User ID.

But instead, the user gets a new visitorId, and that is why the attribution isn't attributed to the first referrer. And the conversion is attributed to a Direct visit.

Br, Jorge

jorgeuos commented 1 year ago

What exactly is the problem?

Last non-direct attribution on ecommerce orders does not work as expected.

What is the possible cause?

Imagine this use Screen Shot 2023-08-04 at 15 57 23

Visit 1

  1. A new visitor comes to the site via an email campaign and their activity is correctly attributed to the campaign.
  2. They remain anonymous during this visit.
  3. Matomo generates a unique Visitor ID

Visit 2

  1. The same visitor comes to the site “directly” 1 hour later
  2. Matomo recognizes them from the Visitor ID set from Visit 1
  3. Their visit is attributed to DIRECT
  4. We see two visits for this visitor in their Visitor profile
  5. The visitor then logs-in and a User ID is sent to Matomo (setUserId).
  6. 🔴 Matomo generates a new Visitor ID
  7. The Visitor completes an Order
  8. The pre and post-login activity is all contained within this visit: Visit 2.. the USER ID binds this activity together (good)
  9. 🔴 The USER ID is not assigned to Visit 1
  10. The attribution of the order to EMAIL is lost because that belongs to visit 1 but it has no relationships to the USER ID who made the booking in VISIT 2 (bad)

Key questions

Is it expected behaviour that a new Visitor is generated once a UserId is provided to Matomo?

  1. If YES, surely Visit 1 (all previous visits) should be assigned to the USER?
  2. If NO, then what is causing it to be regenerated?

Regards, Me and my client

MatomoForumNotifications commented 1 year ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/multi-channel-conversion-attribution-last-non-direct-doesnt-work/52828/6

jorgeuos commented 1 year ago

I think that post 👆 could help us with getting the reports that we need.

sgiehl commented 1 year ago

@jorgeuos I don't have enough time to think that all through in detail, but to me it sounds more like this would be a problem around the user id tracking. If you wouldn't use user ids I guess the attribution would be correct all over, is that right?

If setting a user id later in a visit creates a new visit, that sounds incorrect to me and might be what we should investigate. Can you confirm that?

michalkleiner commented 1 year ago

@sgiehl perhaps somewhat related to #21156 where assigning user ID also creates a new visitor?

jorgeuos commented 1 year ago

@sgiehl

Yes, that is my understanding.

However, the documentation says:

However, once that user logs into their account and you set a User ID for this visitor, then all actions such as page views are linked to the User ID and not the visitor ID.

https://matomo.org/faq/general/how-are-requests-with-a-user-id-tracked/

When a user is trying to finish a purchase, they get logged in. Shouldn't the referrer and attribution also be updated and associated with the userID and not the visitorID.

I will consult with my client if it is an option for them to turn off the userID. At least until the issue is resolved or until we find a workaround.

sgiehl commented 1 year ago

Thanks for the response. I guess we at least need to investigate why the documentation and how the code behaves is different. One part seems to be wrong in that case.

mattab commented 1 year ago

Thanks for the detailed issue, very appreciated.

@sgiehl Q: Is this maybe the same issue as https://github.com/matomo-org/matomo/issues/19927 ?

jorgeuos commented 1 year ago

Hi @mattab

Yes, indeed, the two problems looks related. I'm sorry that I didn’t catch that sooner.

However, there seems to be several issues in the forum related to this issue and I understand that you are looking into it with your best effort.

Please let me know if there is something I can do to make it smoother for you to troubleshoot and pinpoint the error.

A further break down:

jorgeuos commented 12 months ago

Update: Based on recent discussions and observations:

  1. Impact of Removing UserId: By removing the UserId, we've witnessed a big impact on data. Notably, metrics such as the bounce rate, unique pageviews, and others have shown marked improvements. This adds further weight to the core issue identified earlier – the problematic handling of visits when a UserId is set.

  2. Alignment of Data Post Removal: After removing the UserId, we've observed that certain data metrics (like the “CAMPAIGN” bookings and “SOURCE MEDIUM” bookings) align closely post our change. This supports the fact that Matomo isn't treating UserId in the manner it should, thereby causing discrepancies.

  3. Broader Implications: We are in the process of conducting comparisons across all of our sites to see if this pattern is consistent. If all sites show same thing, it will confirm the problem is not just one place, but everywhere.

  4. Next Steps: We found part of the problem, which is good. But, how to use UserId effectively is the next challenge. We need to fix how UserId is managed to get right data and also keep track of users properly.

Given these updates and the previously discussed concerns, any insights or recommended action steps from your end would be valuable. We're committed to collaborating closely on this, ensuring we arrive at a comprehensive solution.

MatomoForumNotifications commented 10 months ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/setconversion-attributionfirstreferrer-is-not-working/53798/2

AdamMcAddEm commented 2 months ago

My organization selected Matomo to replace UA because of their default support for last-touch non-direct attribution. As we poked around in the platform, we realized that this isn't what was happening at all in the system and that it was more of a last touch attribution setup. Then after a bit of searching, I discovered this thread and see that this is an issue that's been around and known for OVER A YEAR. We're incredibly upset that a feature that Matomo is advertising hasn't been available for over a year as we sit on the eve of our transition away from UA. Can we please pick this up? Or at the very least can Matomo stop advertising features that they don't have @mattab ?

Matomo Last Touch Non Direct issue V2

mattab commented 2 months ago

@AdamMcAddEm As far as we know, attribution works perfectly well in Matomo. We could be wrong but we still haven't been able to reproduce an issue.

The issue you referring to is only a Cosmetic issue, but I agree it's very annoying. This will be addressed ASAP in https://github.com/matomo-org/matomo/issues/19328

AdamMcAddEm commented 2 months ago

@AdamMcAddEm As far as we know, attribution works perfectly well in Matomo. We could be wrong but we still haven't been able to reproduce an issue.

The issue you referring to is only a Cosmetic issue, but I agree it's very annoying. This will be addressed ASAP in #19328

Yes, I investigated again, and it does look like the attribution of revenue/conversions is working. GA would just also attribute the sessions so that our conversion rates would be more accurate.

Example Visitor 1

Visitor 2

GA Email - 2 purchases, 33% conversion rate (6 visits, 2 purchases)

Matomo Email - 2 purchases, more than 50% conversion rate (4 visits, 2 purchases)

Let me know if I'm misunderstanding something.