Issues with campaign handling

Hello and Happy New Year!

I have an issue with Matomo on a single page application website related to campaign tracking.

Here is the situation:

  1. I land on the site with correct and valid campaign parameters. I see the the correct cookies are created and specifically, pk_ref is set. I can navigate around and my actions are bound to a single visit and correctly recorded in Matomo.

  2. Within the same 30 minute timeframe, I revisit the site with a different campaign name. The first page view is correctly registered with these new campaign details. However, the second page view of this “visit” generates a new visit reverting back to use the values stored in the pk_ref cookie from the first visit.

I have tried a multitude of ways to overcome this (I am using the Javascript tracker) ~ and I am not a programmer :frowning: I have conducted many searches in this forum and beyond and this is the same issue as mentioned here: https://github.com/matomo-org/matomo/issues/12218#issuecomment-339364512

Ideally, the behaviour I would expect is this:

The value stored in the pk_ref cookie should be from the latest visit including the current active visit.

The campaign details of the current active visit should never be overwritten with values from the cookie

Has anyone had any experience of this? Any help would be greatly appreciated.

Hi @mattukplym
Maybe have a look at:

Thanks @heurteph-ei

Ive read and re-read that post. Can I ask a question (sorry if it’s dumb but I am struggling to put 2 and 2 together)?

In the situation above, what I see in my case is three visits:

I enter with campaign (?mtm_campaign=test1)
Visit 1 - attributed to test1: I navigate a few pages and all actions are logged under this visit

I leave the site and re-enter with campaign (?mtm_campaign=test2)
Visit 2 - attributed to test2: My first page view is logged. I then navigate to another page and…

Visit 3 - All subsequent activity is attributed back to campaign #1

Do you know how I can force subsequent activity on visit 2 to remain on visit 2.

I am using the javascript tracker on an SPA. Ive tried all sorts of combinations of setting the referrer url but have had no joy.

Probably the cookie is set to test1 and not updated later… (I am not expert on campaigns)
Then because the URL contains test2 on 1st page of 2nd visit, it is linked to campaign test2, and because the cookie would not update, (and URL doesn’t contain the campaign anymore), following pages are attributed to test1
Try maybe to keep the mtm_campaign (with its value) on further page URLs? (you can “rewrite” URLs in Matomo)

I saw also this: