Attribution: number of first and last touches in two columns

Link to the lesson

Does this query calculates number of first and last touches for each campaign?
Numbers in two columns are the same, so I guess it doesn’t.

WITH 
  first_touch AS (
    SELECT user_id,
        MIN(timestamp) AS 'first_touch_at'
    FROM page_visits
    GROUP BY user_id),

  last_touch AS (
    SELECT user_id,
        MAX(timestamp) AS 'last_touch_at'
    FROM page_visits
    GROUP BY user_id)
SELECT 
  page_visits.utm_campaign,
  COUNT(first_touch.first_touch_at) AS 'first touches #',
  COUNT(last_touch.last_touch_at) AS 'last touches #'
FROM page_visits
JOIN first_touch
  ON first_touch.user_id = page_visits.user_id 
JOIN last_touch
  ON last_touch.user_id = page_visits.user_id 
WHERE page_name = '4 - purchase'
GROUP BY utm_campaign
ORDER BY COUNT(utm_campaign) DESC;

Please help find out the solution.
Kind regards

You combined steps/questions 3 & 4 and the CTEs need to be separate.

Create the temp table with first_touch first, and then:

SELECT ft.user_id,
    ft.first_touch_at,
    pv.utm_source,
		pv.utm_campaign,
    COUNT(utm_campaign)
FROM first_touch ft
JOIN page_visits pv
    ON ft.user_id = pv.user_id
    AND ft.first_touch_at = pv.timestamp 
    GROUP BY pv.utm_campaign
    ORDER BY 5 DESC;

Then you do the same for last_touch