Page referrer
CNIL recommendation
The removal of external referrer information;
Solution
The page_referrer field should be retained for internal links, but removed for external links. In practice, if the page_referrer domain corresponds to that of the website, this field is retained. Otherwise, it should be left blank.
We start by creating a variable containing our page_referrer.
Variables > New:
- Variable name:
GA4 - Page Referrer
Variable type: Event Data- Key Path:
page_referrer
Next, we create a second variable that will allow us to retrieve only the page_referrer domain. To do this, we'll use Simo Ahava's 'URL Parser' variable template.
Variables > New:
- Variable name:
GA4 - Page Referrer Domain
> - Variable type: URL Parser- Variable type: URL Parser (via Community Template Gallery)
- URL Source:
{{GA4 - Page Referrer}}
(created previously)- Component Type: Host Name
- Strip 'www': true
And the last variable to create is the page_referrer that we'll send to Google, which will be either empty or filled depending on the origin.
Variables > New:
- Variable name:
GA4 - Page Referrer Pseudonymized
- Variable type: Lookup Table
- Input Variable:
{GA4 - Page Referrer Domain}}
(our previously created domain)- Output Variable: (list of our authorized domains)
- input: example1.com / output:
{{GA4 - Page Referrer}}
- input: example2.com / output:
{{GA4 - Page Referrer}}
- Set default value:
true
(leave default empty)
We need to use this last variable in the configuration of the GA4 tag by adding a page_referrer
field to the list of fields to be added/modified and assigning it this value.