Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] If custom campaign parameters are set up in the config.ini.php, Matomo detects a new visit on any non-pageview action #157

Open
peterbo opened this issue Jul 17, 2024 · 19 comments

Comments

@peterbo
Copy link

peterbo commented Jul 17, 2024

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):

mtm-utm

When commented out, actions are correctly attributed to the initial visitor:

mtm-utm1

@AltamashShaikh
Copy link
Contributor

@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
Screenshot from 2024-07-18 08-01-21

@araichyk @snake14 are you guys able to reproduce this issue locally ?

@peterbo peterbo changed the title [Bug] If custom campaign parameters are set up in the config.ini.php, Matomo detects a new visit on any action [Bug] If custom campaign parameters are set up in the config.ini.php, Matomo detects a new visit on any non-pageview action Jul 18, 2024
@peterbo
Copy link
Author

peterbo commented Jul 18, 2024

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):
cmp-split-test

@AltamashShaikh
Copy link
Contributor

@peterbo Still works as expected for me.

Screenshot from 2024-07-19 07-06-58

@peterbo
Copy link
Author

peterbo commented Jul 19, 2024

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.

@sgiehl
Copy link
Member

sgiehl commented Jul 19, 2024

@peterbo did you maybe change the configuration create_new_visit_when_campaign_changes or create_new_visit_when_website_referrer_changes?

@peterbo
Copy link
Author

peterbo commented Jul 19, 2024

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)

@sgiehl
Copy link
Member

sgiehl commented Jul 19, 2024

@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: matomo-org/matomo#18511

@peterbo
Copy link
Author

peterbo commented Jul 19, 2024

Core parameters are unmodified, so there is definitely an overlap with the MarketingCampaignsReporting settings.

@snake14
Copy link
Contributor

snake14 commented Jul 23, 2024

@AltamashShaikh I was unable to reproduce. All events were tracked under the same visit despite providing multiple campaign parameters.

@peterbo
Copy link
Author

peterbo commented Jul 23, 2024

@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.

@AltamashShaikh
Copy link
Contributor

@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"

@peterbo
Copy link
Author

peterbo commented Jul 23, 2024

@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):
test5-11

@AltamashShaikh
Copy link
Contributor

@peterbo I just tested this scenario for a Matomo Cloud instance and I can confirm I see test2 as the referer_name always

@peterbo
Copy link
Author

peterbo commented Jul 23, 2024

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.

campaign_name

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.

@AltamashShaikh
Copy link
Contributor

@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"

@AltamashShaikh
Copy link
Contributor

@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"

@AltamashShaikh
Copy link
Contributor

@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"

@AltamashShaikh
Copy link
Contributor

@peterbo The fix won't work in 100% case and it actually be fixed by matomo-org/matomo#20067

@peterbo
Copy link
Author

peterbo commented Jul 24, 2024

@AltamashShaikh thanks for your efforts for finding & fixing this!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants