Open peterbo opened 4 months ago
@peterbo I tried replicating the same on my local instance and seems to work as expected
URL: http://localhost.demo.com/test.html?mtm_campaign=test2&utm_campaign=test3
Config
[MarketingCampaignsReporting]
campaign_keyword = "mtm_keyword,matomo_kwd,mtm_kwd,utm_term"
campaign_source = "mtm_source,utm_source"
campaign_medium = "mtm_medium,utm_medium"
campaign_content = "mtm_content,utm_content"
campaign_id = "mtm_cid,utm_id"
campaign_group = "mtm_group"
campaign_placement = "mtm_placement"
Visits log dashboard
@araichyk @snake14 are you guys able to reproduce this issue locally ?
Sorry, I forgot to mention an important detail: Only non-pageview actions are affected.
Try to execute:
_paq.push(['trackEvent', 'Testevent', 'Test123']);
_paq.push(['trackEvent', 'Testevent', 'Test123']);
_paq.push(['trackEvent', 'Testevent', 'Test123']);
After loading the landingpage. These actions will be splitted (tested in another 5.1.0 instance):
@peterbo Still works as expected for me.
It's strange, because I also found one instance, where this wasn't reproducible. I'm trying to find additional settings / plugins / things that these have in common, that might be involved in this.
@peterbo did you maybe change the configuration create_new_visit_when_campaign_changes
or create_new_visit_when_website_referrer_changes
?
Hey @sgiehl - the setting is the default (create_new_visit_when_campaign_changes = 1). When set to 0, it works correctly (all actions attributed to one session)
@peterbo have you configured core and the plugin with the same parameters for campaigns? If not this might be the same issue as described here: https://github.com/matomo-org/matomo/issues/18511
Core parameters are unmodified, so there is definitely an overlap with the MarketingCampaignsReporting settings.
@AltamashShaikh I was unable to reproduce. All events were tracked under the same visit despite providing multiple campaign parameters.
@AltamashShaikh which parameters did you test? I can see, that the campaign in your test is "test2" from the mtm_campaign parameter. If the config is set correctly, in my instances, Matomo always uses the utm_campaign parameter "test3". Did you enable / modify the config parameter "create_new_visit_when_campaign_changes"?
Additionally, the bug only occurs, if both parameters have different values. I guess, that somewhere, there is an if-statement that compares the value of the other campaign-parameter with the currently attributed campaign and therefore always recognizes a new campaign with every action. Therefore a new visit.
@peterbo My local URL is http://localhost.demo.com/test.html?mtm_campaign=test2&utm_campaign=test3
and it seems to pickup mtm_campaign
query params, due to campaign_var_name
config setting I assume.
campaign_var_name = "pk_cpn,pk_campaign,piwik_campaign,mtm_campaign,matomo_campaign,utm_campaign,utm_source,utm_medium"
@AltamashShaikh - in my instances, campaign_var_name is also set (default setting like yours).
In Debug mode, I can see the following for the events that get split:
DEBUG Referrers[2024-07-23 09:04:14 UTC] [a02d7] Referrers\Base::isReferrerInformationNew: detected change in referer_name ('test5' != 'test4').
Request (campaign test4 was recognized clientside):
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] Debug enabled - Input parameters: array (
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'e_c' => 'Testevent',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'e_a' => 'Test123',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'ca' => '1',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'idsite' => '1',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'rec' => '1',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'r' => '881666',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'h' => '11',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'm' => '4',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 's' => '15',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'url' => 'https://example.org/?mtm_campaign=test4&utm_campaign=test5',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] '_id' => '',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] '_idn' => '1',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'send_image' => '1',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] '_rcn' => 'test4',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] '_refts' => '1721725455',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'pv_id' => 'cpPJxk',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] 'uadata' => '{}',
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [2ec9d] )
DEBUG Piwik\Tracker[2024-07-23 09:04:14 UTC] [eeff7] Current datetime: 2024-07-23 09:04:14
Screenshot from Visitor Log (Campaign test5 was recognized serverside):
@peterbo I just tested this scenario for a Matomo Cloud instance and I can confirm I see test2 as the referer_name always
Oh I just saw, that your whole config for campaign_name (see https://plugins.matomo.org/MarketingCampaignsReporting) is missing from your [MarketingCampaignsReporting] config.ini.php. If you add this, you'll be able to reproduce. Sorry, I didn't spot this earlier. Thought you also copied that over from the Plugin description.
And I also have an idea, what could be responsible.
The campaign detector of the plugin is working differently than the core detector (plugins/Referrers/Columns/Base.php). The first one is matching the last configured campaign parameter from the list, the core detector is matching the first matching campaign parameter. I checked this by changing the order of the core campaign configuration and putting utm_campaign to the beginning:
campaign_var_name = "utm_campaign,pk_cpn,pk_campaign,piwik_campaign,mtm_campaign,matomo_campaign,utm_source,utm_medium"
With this change, everything works correctly. So this is the problem.
This seems to be an edge case, but is indeed a valid business case. Quite some marketing tools are auto-tagging with utm parameters, while marketers would like to use Matomo parameters with alternative content.
@peterbo I was able to reproduce this one and seems to resolve if I update the config as below
[MarketingCampaignsReporting]
campaign_name = "mtm_campaign,matomo_campaign,mtm_cpn,pk_campaign,piwik_campaign,pk_cpn,utm_campaign"
campaign_keyword = "mtm_keyword,matomo_kwd,mtm_kwd,utm_term"
campaign_source = "mtm_source,utm_source"
campaign_medium = "mtm_medium,utm_medium"
campaign_content = "mtm_content,utm_content"
campaign_id = "mtm_cid,utm_id"
campaign_group = "mtm_group"
campaign_placement = "mtm_placement"
@peterbo I was able to figure out the issue, In core to detect referer_name
, we use the campaign_var_name
config under Tracker
and in MarketingCampaignsReporting we are using the campaign_name
config under MarketingCampaignsReporting
.
When we set below config, and if the URL is http://localhost.demo.com/test.html?mtm_campaign=test2&utm_campaign=test3
Core will detect the referer_name
as test2
since mtm_campaign
is ahead in the list, compare to utm_campaign
, but the plugin detects the referer_name
from campaign_name
config, and here we have only utm_campaign
and hence we detect test3
which is new campaign and we mark it as new visit
[MarketingCampaignsReporting]
campaign_name = "matomo_campaign,mtm_cpn,utm_campaign"
@peterbo This needs a fix in Matomo core, I will try to send a PR, meanwhile to tackle the issue, you can update the config as below
[MarketingCampaignsReporting]
campaign_name = "mtm_campaign,matomo_campaign,mtm_cpn,pk_campaign,piwik_campaign,pk_cpn,utm_campaign"
@peterbo The fix won't work in 100% case and it actually be fixed by https://github.com/matomo-org/matomo/issues/20067
@AltamashShaikh thanks for your efforts for finding & fixing this!!
If custom campaign parameters are set up in the config.ini.php and used alongside standard parameters, Matomo detects a new visit on any action (e.g. https://example.org/?mtm_campaign=test2&utm_campaign=test3 while having [MarketingCampaignsReporting] campaign_name = "utm_campaign" in youf config.ini.php):
When commented out, actions are correctly attributed to the initial visitor: