# Visitors IP as header/query param when using GTM server-side

**URL:** <https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492>\
**Category:** Privacy\
**Created:** [March 2, 2022, 7:16pm UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492 "2022-03-02T19:16:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vitali\_Korezki](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/vitali_korezki/32/269_2.png) [@Vitali\_Korezki](https://community.piwik.pro/u/Vitali_Korezki)\
**Post date:** [March 2, 2022, 7:16pm UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492/1 "2022-03-02T19:16:33Z")

</div>

Dear Piwik community,

for a POC project for one of my clients, I’m looking for a way to bypass the AdBlocker and make sure the Piwik consent banner will be shown always to visitors from GDPR countries. Since the custom subdomain solution with CNAME DNS entry is not working (Piwik shows an error when I try to load the script), I’m using a custom template in GTM server-side integration to load the script, which allows me to use a custom domain + path. So far so good …

Now we are facing the issue on the Piwik side … Piwik Pro uses visitors’ IP addresses to determine which variant of the file to deliver so that visitors from a GDPR country see the banner, whereas others are opted in automatically. When I use GTM server-side integration, Piwik always delivers a version for non-GDPR countries.

In order to solve this issue I’ve tried to set headers like described in the article below, but unfortunately no luck. Maybe I’m missing something … would be great if someone could help me out, how exactly should the headers need to look, so that the “initial” file with Consent Manager is showing the banner to the visitors coming from GDPR countries.

Thanks,  
V

> **[Which HTTP request headers are used by Piwik PRO? | Piwik PRO help center](https://help.piwik.pro/support/questions/which-http-request-headers-are-used-by-piwik-pro/)**
>
> When measuring activity with the tracking API for Piwik PRO, you can use the following HTTP headers: Host: The hostname of the HTTP request, the hostname of the Piwik PRO server Referrer: Used to track referrer information like website, search engine...

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 2, 2022, 9:20pm UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492/2 "2022-03-02T21:20:50Z")

</div>

Hi. Do you mean `X-Forwarded-Proto, X-Forwarded-Host, X-Forwarded-For` ? Those headers require additional whitelisting of IP addresses on the backend side (because otherwise it would impose a security risk on our end). This service is available only as part of the paid plans. So, if your intention is to set up tracking in the first party domain, you have to disable `Ask for consent in countries under the GDPR and UK GDPR` setting.

---

<div class="post-metadata">

**Author:** ![Vitali\_Korezki](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/vitali_korezki/32/269_2.png) [@Vitali\_Korezki](https://community.piwik.pro/u/Vitali_Korezki)\
**Post date:** [March 3, 2022, 5:26am UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492/3 "2022-03-03T05:26:06Z")

</div>

Thanks! I already thought about this as well, but the main objection is I can’t find a way to automatically opt-in visitors outside of GDPR countries. If you have a solution for that, I would really appreciate.

As an alternative, wouldn’t it be easier for Piwik just allow to pass over the visitor IP or visitor country as query parameter?

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 3, 2022, 9:09am UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492/4 "2022-03-03T09:09:32Z")

</div>

I guess you’d have to use javascript API to get the geolocation (there are a few vendors offering such a feature) and then Consent Manager API to automatically opt-in.

> [@Vitali\_Korezki](#):
>
> As an alternative, wouldn’t it be easier for Piwik just allow to pass over the visitor IP or visitor country as query parameter?

It doesn’t matter if it’s a param or http header. In both cases, we have to verify the source that is trying to override the original IP address.

---

<div class="post-metadata">

**Author:** ![Vitali\_Korezki](https://dub1.discourse-cdn.com/flex005/user_avatar/community.piwik.pro/vitali_korezki/32/269_2.png) [@Vitali\_Korezki](https://community.piwik.pro/u/Vitali_Korezki)\
**Post date:** [March 3, 2022, 6:27pm UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492/5 "2022-03-03T18:27:42Z")

</div>

Thank @Admin for the quick reply! I’ve already run a few tests yesterday but got confused a little by the API functionality.

For example, there are two functions to set the consent, one of them allows to set “initial consent”. In my understanding, initial consent is supposed to be a “default” value in case the user hasn’t provided any selection yet … however, it’s not the case. The function “setInitialComplianceSettings” overwrite existing values, which now open the question, how is that different to “setComplianceSettings” function. In addition, even if no consent is provided yet, after using “setInitialComplianceSettings” the visitor does not see the privacy banner, instead of a small message on the left bottom corner “you haven’t provided your consent selection yet”. But maybe I just don’t have a clear understanding of how it’s supposed to be used.

Regarding your comment:

> It doesn’t matter if it’s a param or http header. In both cases, we have to verify the source that is trying to override the original IP address.

My guess would be … since those types of requests only make sense if someone uses a “proxy” or like myself server-side instrumentation, an API key passed over as a parameter could help solve this issue.

---

<div class="post-metadata">

**Author:** ![Admin](https://avatars.discourse-cdn.com/v4/letter/a/3ec8ea/32.png) [@Admin](https://community.piwik.pro/u/Admin)\
**Post date:** [March 4, 2022, 9:58am UTC](https://community.piwik.pro/t/visitors-ip-as-header-query-param-when-using-gtm-server-side/492/6 "2022-03-04T09:58:23Z")

</div>

Maybe this article will be helpful: [How to integrate 3rd party consent tool with Piwik PRO anonymous tracking?](https://community.piwik.pro/t/how-to-integrate-3rd-party-consent-tool-with-piwik-pro-anonymous-tracking/128)

According to the docs, it notifies the system about the fact, that user [has already seen the form and did not submit it.](https://developers.piwik.pro/en/latest/consent_manager/js_api/index.html#set-initial-compliance-settings) It explains the fact of showing a reminder. You can hide the reminder by using `setComplianceSettings`.

> [@Vitali\_Korezki](#):
>
> My guess would be … since those types of requests only make sense if someone uses a “proxy” or like myself server-side instrumentation, an API key passed over as a parameter could help solve this issue.

Yes. We verify it currently by using sharing secret. Unfortunately, it’s available only in the paid version.
