matomo-org / plugin-MarketingCampaignsReporting

GNU General Public License v3.0
25 stars 19 forks source link

Most Campaign Stats are empty after upgrading from 4 to 5 #159

Closed pschrammel closed 2 months ago

pschrammel commented 3 months ago

As reported here:

The campaign parameters are in the DB but not shown in the UI. Only campaign name and search params UI are showing data. All others (medium,....) are empty.

Plugin Version: 5.0.4 Matomo-Version: 5.1.0 MySQL-Version: 10.6.17-MariaDB-log PHP-Version: 8.2.22

AltamashShaikh commented 3 months ago

@matomo-org/core-team Could this be due to implementation of disableCampaignParameters in Matomo 5.1.0 ?

pschrammel commented 2 months ago

@AltamashShaikh how can I test your assumption?

AltamashShaikh commented 2 months ago

@pschrammel You can try to update your tracking code, by calling _paq.push(['enableCampaignParameters']); before _paq.push(['trackPageView']); and see if it tracks any campaign information or not.

praveentharindu commented 2 months ago

@AltamashShaikh I tried the above method (before the _paq.push(['trackPageView']) ) with our current Matomo implementation (5.1.0), but I encountered the following error. Additionally, I looked for the enableCampaignParameters method in our matomo.js file but couldn't find it. Could that be the reason? Screenshot from 2024-09-10 14-38-44

Thanks!

snake14 commented 2 months ago

Hi @praveentharindu . You're right. It appears that method was removed before Matomo 5.1.0 was released. As far as I can tell, that setting is defaulted on and can only be disabled. So, unless you're calling disableCampaignParameters, it should be enabled. It looks like it also checks consent. Does your setup require consent? A good way to check is by running this in your console after loading the page: window.Matomo.getAsyncTrackers()[0].isConsentRequired();.

Another thing to check is your config.ini.php file and make sure that the expected campaign parameters are configured correctly. For example, I have the following in my config.ini.php file:

[MarketingCampaignsReporting]
campaign_name = "matomo_campaign,mtm_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,mtm_clid"
campaign_group = "mtm_group"
campaign_placement = "mtm_placement"
praveentharindu commented 2 months ago

@snake14 Thank you for the confirmation. I'll check those.

pschrammel commented 2 months ago

Thx for your efforts. I think the problem is not in the frontend. The data gets into the DB and also in the live feed we can see the data. But on the accusition page it's not shown: grafik

but in aquisition you don't see all the data

grafik

snake14 commented 2 months ago

Hi @pschrammel . Thank you for the images illustrating the issue. Does the data show up for past days in the Acquisition > Campaigns report? I just tested in my local Matomo instance and noticed that the campaign parameters showed almost immediately in the Visitor log, but didn't show up in Acquisition until archiving had completed for that day.

pschrammel commented 2 months ago

We run the cron:archive task every hour. So for the second image I had to wait some time. The realtime data is immidiate (first image). But as said, only names and keywords are extracted not the other params. More details:

do we call archive wrongly?

snake14 commented 2 months ago

@pschrammel I'm not sure what all the other scripts do, but console core:archive should run the archiving process. Any ideas @AltamashShaikh ?

AltamashShaikh commented 2 months ago

@pschrammel Can you check if you see the columns campaign_* in log_visit table and there is some entry when you run below query ?

Screenshot from 2024-09-13 07-43-20

SELECT * FROM `matomo_log_visit` where campaign_medium is not null order by visit_last_action_time desc limit 20
pschrammel commented 2 months ago

I modified the query: SELECT * FROM log_visit where campaign_group = 'group2' order by visit_last_action_time desc limit 20;

our db tables are not prefixed and I got a bunch of results but I think this is the relevant: as I said all mtm_ params seems to be there:

| 49658982 | 4 | fh-9��� | 2024-07-24 13:58:40 | cPJ�g� | .�g | 0 | NULL | 2024-07-24 13:20:15 | 0 | 0 | 0 | 0 | NULL | 1 | 8 | 83 | 8 | 83 | 14 | 7 | 0 | param2 | test2 | 6 | https://teams.microsoft.com/ | en-us | Blink | CH | 125.0 | 1 | | generic desktop | 0 | LIN | 6.5 | 7 | 15:20:15 | 0 | 2560x1440 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2306 | M�nster | de | 51.961000 | 7.626000 | NW | NULL | NULL | NULL | NULL | NULL | u_6d97b24c-1b71-4396-9485-81cc848251e0 | content2 | group2 | id2 | param2 | medium2 | test2 | placement2 | source2 | ff602862-5e42-4c3a-bdf5-c7e944f2f98d | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | xxxxx | 0 | NULL | 2024-07-24 05:35:09 | 0 | 0 | 0 | 0 | NULL | 1 | 8 | 83 | 8 | 83 | 2 | 1 | 0 | param2 | test2 | 6 | | de | Gecko | FF | 128.0 | 1 | | generic desktop | 0 | UBT | | 1 | 07:35:09 | 0 | 3840x2160 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 | Berlin (Bezirk Tempelhof-Sch�neberg) | de | 52.465000 | 13.396000 | BE | NULL | NULL | NULL | NULL | NULL | u_f19b349a-3fc1-4d26-993a-96129770439d | content2 | group2 | id2 | param2 | medium2 | test2 | placement2 | source2 | 0f415f38-826e-4b98-bb98-d26cbb9fea85 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |

AltamashShaikh commented 2 months ago

@pschrammel If you see the data visit_last_action_time is 2024-07-24 13:58:4 and it looks like there is no recent data in this database

pschrammel commented 2 months ago

sorry, wrong row, here's the one from Sept 11th matching the visit above | 49660211 | 4 | ��J�$�� | 2024-09-11 05:25:53 | Ȕ����B | �< | 0 | NULL | 2024-09-11 05:25:52 | 0 | 1 | 0 | 0 | NULL | 1 | 8 | 83 | 8 | 83 | 2 | 1 | 0 | param2 | test2 | 6 | | de | Gecko | FF | 129.0 | 1 | | generic desktop | 0 | UBT | | 1 | 07:25:52 | 0 | 3840x2160 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 2 | Berlin (Bezirk Tempelhof-Sch�neberg) | de | 52.465000 | 13.396000 | BE | NULL | NULL | NULL | NULL | NULL | u_f19b349a-3fc1-4d26-993a-96129770439d | content2 | group2 | id2 | param2 | medium2 | test2 | placement2 | source2 | 0f415f38-826e-4b98-bb98-d26cbb9fea85 | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL | NULL |

AltamashShaikh commented 2 months ago

@pschrammel If there is data, same should be shown when the data is archived. You can try invalidating reports for 11th September and try to archive again and see if it helps

pschrammel commented 2 months ago

ran: /opt/bitnami/matomo/console core:invalidate-report-data --dates=2024-09-11

no data in the view for Sept 11 any more

/opt/bitnami/matomo/console core:archive --force-date-range=2024-09-10,2024-09-16

now I see the data: grafik

so....did we setup archiving wrong?

AltamashShaikh commented 2 months ago

@pschrammel Good to hear that you can see the data now, possible that your archiving might not be running as expected. You can follow this guide on how to setup cron fro Matomo archiving.

You could also set the cron to execute this command every hour via crontab

5 * * * *  /opt/bitnami/matomo/console core:archive --url={YOUR_<MATOMO_URL} > /opt/bitnami/matomo/tmp/logs/archive.log

Or via specific user

5 * * * * {web-user-like-www-data}  /opt/bitnami/matomo/console core:archive --url={YOUR_<MATOMO_URL} > /opt/bitnami/matomo/tmp/logs/archive.log

@pschrammel Can we close this issue now ?

pschrammel commented 2 months ago

hm....we run the archive job (without any params) every hour (10 )

pschrammel commented 2 months ago

I found the bug/solution. Pointing us to the archiving task was the key.

We run a matomo on k8s with a web pod for serving the http server and a cronjob for archiving. In the webcontainer the campaignplugin was activated in the cronjob's container it wasn't. When I ran the invalidation and rearchiving I ran it in the web container as the cronjob container is not permanent. So it worked. But not in the cronjob. This led to the strange effect above.

Activating the plugin also in the image of the cronjob was the solution.

Thx to all of you for your quick responses and guiding me to the solution.