# Disable Hubspot tracking code with Wordpress plugin

**URL:** <https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931>\
**Category:** CMS Development\
**Created:** [August 6, 2021, 7:50am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931 "2021-08-06T07:50:52Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![tvaudelin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tvaudelin/32/21752_2.png) [@tvaudelin](https://community.hubspot.com/u/tvaudelin)\
**Post date:** [August 6, 2021, 7:50am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/1 "2021-08-06T07:50:52Z")

</div>

Hi there !

We are currently using the Hubspot Wordpres plugin for tracking and embed forms into our pages/posts.

As the HubSpot cookie settings banner did not suit us (_this is not the discussion here please_), we decided to implement a third party tool to manage cookies through GTM called “Axeptio”.

**The issue :**

Since the wordpress plugin inserts the tracking code automatically, I cannot enable it only if the user accepts the HubSpot tracking cookies which causes our website to not follow GDPR rules.

**The questions :**

1. Is there a way to programmatically disable HubSpot tracking when using the Wordpress plugin while keeping the use of forms ?
2. Is there a way to implement HubSpot forms into our websites without the Wordpress plugin ? (so that I can manually implement the tracking code through GTM).

I’m open to any alternatives if anybody has had this issue in the past.

Thanks in advance,

Thibault

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [August 6, 2021, 8:32am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/2 "2021-08-06T08:32:21Z")

</div>

Hi @tvaudelin, here is some [documentation](https://legacydocs.hubspot.com/docs/methods/tracking_code_api/tracking_code_overview) about the tracking script. You can use Javascript to revoke all tracking with \_hsq.push([‘doNotTrack’]);. Sadly, this also blocks anonymized data. You can read more about this specific cookie here: [https://legacydocs.hubspot.com/docs/methods/tracking\_code\_api/place\_do\_not\_track\_cookie](https://legacydocs.hubspot.com/docs/methods/tracking_code_api/place_do_not_track_cookie).

You can reenable tracking again by removing the added \_\_hs\_do\_not\_track cookie and refresh the page.

---

<div class="post-metadata">

**Author:** ![tvaudelin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tvaudelin/32/21752_2.png) [@tvaudelin](https://community.hubspot.com/u/tvaudelin)\
**Post date:** [August 6, 2021, 9:58am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/3 "2021-08-06T09:58:50Z")

</div>

Perfect, solved my problem, thanks [@TE](https://community.hubspot.com/t5/user/viewprofilepage/user-id/8733) !  
For anyone trying to fix the same thing, I created a two new tags on GTM: one that enables the “doNotTrack” cookie when axeptio returns the enable event and the second one that disables it when axeptio returns the disable event.  
Problem solved !

---

<div class="post-metadata">

**Author:** ![SRicca](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/sricca/32/41549_2.png) [@SRicca](https://community.hubspot.com/u/SRicca)\
**Post date:** [August 27, 2021, 11:05am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/4 "2021-08-27T11:05:26Z")

</div>

Please, could you provide us the correct GTM codes?

Many thanks

---

<div class="post-metadata">

**Author:** ![tvaudelin](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tvaudelin/32/21752_2.png) [@tvaudelin](https://community.hubspot.com/u/tvaudelin)\
**Post date:** [August 27, 2021, 12:50pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/5 "2021-08-27T12:50:21Z")

</div>

Hey @SRicca,

Here is the code I ended up using. Simple and works like a charm !

If cookie is refused (disable tracking) :

```lia-code-sample
<script>
 (function() {
 _hsq.push(['doNotTrack']);
 })();
</script>

```

If cookie is accepted (re-enable tracking) :

```lia-code-sample
<script>
 (function() {
 _hsq.push(['doNotTrack', {track: true}]);
 })();
</script>

```

Hope it helps !

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [November 14, 2021, 9:06pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/6 "2021-11-14T21:06:34Z")

</div>

Hello. Are you sure that pushing the \_\_do\_not\_track cookie works and Hubspot doesn’t add the rest of their cookies?

For example, we’ve tried to programatically set the `_\_\_hs\_do\_not\_track_` and `_\_\_hs\_opt\_out_` cookies with `yes` value, **before** we inject the `_[js.hs-scripts.com](http://js.hs-scripts.com)_`. This works good if the cookie policy banner is enabled in the Hubspot Settings. However, if we disable the cookie policy from there (so we don’t show Hubspot’s banner), Hubspot’s script doesn’t seem to respect those values and fills in the browser with the tracking cookies. And if we keep it enabled, then how do we start tracking afterwards, without refreshing the page?

---

<div class="post-metadata">

**Author:** ![RvanBakel](https://avatars.discourse-cdn.com/v4/letter/r/8dc957/32.png) [@RvanBakel](https://community.hubspot.com/u/RvanBakel)\
**Post date:** [December 8, 2021, 10:13am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/7 "2021-12-08T10:13:32Z")

</div>

Hi Teun,

I’ve tried your solution, what would work perfect for our case.

I’ve implemented all of it in GTM and our custom cookie consent banner and what it does, is that it places an extra Hubspot cookie \_\_hs\_do\_not\_track. This cookie is placed on the very first event that happens when a new visitor comes to our website. Though this cookie is in place a.s.a.p., other cookies of Hubspot (like hubspotutk, \_\_hssc, etc.) are still placed.  
Is it correct that these cookies are still placed, but the cookie \_\_hs\_do\_not\_track prevents sending data to Hubspot? Or is something going wrong with my implementation?

If it is correct that cookies are still being placed, but don’t send data, it’s still not GDPR proof as I understand.

Thanks for your answer!

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [December 8, 2021, 11:22am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/8 "2021-12-08T11:22:58Z")

</div>

Hi @RvanBakel ,

The cookies will still be placed, but no longer collect any data. I suppose, because they no longer have tracking functionality, you can categorize these cookies as ‘functional’ cookies. However, I would like to advice you to discuss this with someone with a bit more legal knowledge.

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [December 8, 2021, 11:58am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/9 "2021-12-08T11:58:19Z")

</div>

Hi @Teun ,

I’ve tested your assumption and unfortunately doesn’t seem to be true. Even though we’ve set up the \_\_hs\_do\_not\_track, Hubspot’s scripts still send tracking requests, including identification and the above mentioned cookies:

 ![Screenshot 2021-12-08 at 13.55.40.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/b/7/b71aef8074d8cfdbb5352bbd2e206fc099282466.png)

I’m wondering why isn’t this a bug, since it works correctly (i.e. doesn’t place cookies and doesn’t send tracking requests) if the Hubspot’s cookie banner is enabled, but doesn’t work correctly (places cookies **and** sends tracking information) if the cookie banner is disabled.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [December 8, 2021, 12:05pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/10 "2021-12-08T12:05:57Z")

</div>

Hi @CStefan ,

Do you place the do\_not\_track cookie using the tracking code API?

`_hsq.push(['doNotTrack']);`

If this is placed directly when the page is loaded, it should prevent any data from being sent according to the [docs](https://legacydocs.hubspot.com/docs/methods/tracking_code_api/place_do_not_track_cookie). If this is not the case, this sounds like a major bug.

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [December 8, 2021, 12:30pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/11 "2021-12-08T12:30:28Z")

</div>

Yes, We are including the following script tag (for testing purpose) before loading the hs-scripts:

 ![Screenshot 2021-12-08 at 14.28.27.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/7/73ccb96dfe487a0e777e337fe1caab7564e3ac17.png)

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [December 8, 2021, 5:58pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/12 "2021-12-08T17:58:52Z")

</div>

Could it be that executing the script before loading the tracking script is causing the issue? Is the cookie placed with the code you’re using?

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [December 8, 2021, 10:37pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/13 "2021-12-08T22:37:40Z")

</div>

I’m sorry, but I didn’t understand what you meant. What I’m doing is:  
1. run the script above, pushin “doNotTrack” into `window.hsq`.  
2. load the `\<script src=“[https://js.hs-scripts.com/xxx.js](https://js.hs-scripts.com/xxx.js)” type=“text/javascript”\>\</script\>` tag, loading Hubspot script;  
3. check out storage, noticing the `hubspotutk`, `__hssc` etc. cookies, and check out network requests, noticing tracking calls such as the ones I linked above.  
I’ll try to replicate this in a very very simple sample app.

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [December 8, 2021, 11:11pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/14 "2021-12-08T23:11:43Z")

</div>

@Teun, I’ve made a very very simple test app: [https://hubspotisnotgdprcompliant.web.app/](https://hubspotisnotgdprcompliant.web.app/). It only contains pushing the `doNotTrack` and then loading the Hubspot script. Please load the page and notice:  
1. `doNotTrack` was loaded, as the \_\_hs\_do\_not\_track was placed automatically by HS script;

2. tracking cookies were placed, containing unique user identifier (`hubspotutk`, `__hssc` , etc.);

 ![Screenshot 2021-12-09 at 01.10.36.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/1/31d96ad16de49dc4f0258c9c66b98135ebdfdd10.png)

3. tracking calls are being made, containing the above unique user identifier, for example:

 ![Screenshot 2021-12-09 at 01.10.18.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/9/5/95f99491efc4062ead2d303baf94ffce1c2d0271.png)

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [December 9, 2021, 7:08am UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/15 "2021-12-09T07:08:41Z")

</div>

Hi @CStefan ,

Thank you for testing this so thoroughly. This is definitely not the behaviour I expected from the \_\_hs\_do\_not\_track cookie. The only thing I can imagine is that it prevents the tracking data from getting associated with a specific contact.  
@dennisedson Could you verify this for me?

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [December 12, 2021, 8:29pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/16 "2021-12-12T20:29:47Z")

</div>

Hi. Do you have any updates on this topic?

---

<div class="post-metadata">

**Author:** ![CStefan](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/cstefan/32/93635_2.png) [@CStefan](https://community.hubspot.com/u/CStefan)\
**Post date:** [December 8, 2021, 2:07pm UTC](https://community.hubspot.com/t/disable-hubspot-tracking-code-with-wordpress-plugin/41931/17 "2021-12-08T14:07:22Z")

</div>

As such, my theory is that there’s a serious bug regarding this somewhere in the hubspot script, especially since it has a different behaviour based on whether the cookie banner is enabled or not. Unfortunately, I couldn’t find any place to report this as a bug, so it would be great if you could report it.  
PS: I believe this is a quite serious issue, because other customers might just be trusting the docs and not verifying the results, thus believing they are GDPR compliant, while they are not really compliant and breaking the regulations.
