APIs & Integrations

Non applicable

Issues in Hubspot customized tracking code

Hi everyone,
[Need some help regarding Hubspot customized trackign code]
Since the General Data Protection Regulation (GDPR) came into force on 25th May we start taking consent from all the visitors that they are being tracked by Google Analytics and Hubspot tracking code. Now when someone landed on our website (www.ascertia.com) a pop up appear at the bottom with our updated privacy policy link along with "I agreed" button.

We have customized our Google Analytics and Hubspot tracking codes so that when someone clicks on "I agreed" button ONLY then GA and Hubspot tracking code should trigger.

Now even people are clicking on "I agreed" button, Google Analytics code is triggering fine BUT hubspot code is not triggering every time (As a result showing only 20-25% traffic).
I've generated ticket regarding this issue on Hubsot support but they are unable to resolve the issue and asked me to post the Query here in this developer community.

Hubspot support says that since we have done some customization in the Hubspot tracking code, as a result its not working.
We are looking for such a customized code which must trigger once visitor gives consent.
You can check the current customized hubspot code by viewing source of www.ascertia.com.

Please note that must use our customized banner as consent taking pop up. We can't use Hubspot consent banner as it does not allow Google Analytics code to trigger also.

Looking for possible solution as sson as possible because this issue is becoming a blocker for us and we are not getting right stats from Hubspot.
Thanks

0 Votes
7 Réponses
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Issues in Hubspot customized tracking code

Hi @osamanaseem,

I don't have any tutorials or video walkthroughs, but the process can be broken down as follows:

  1. Call the 'Get privacy consent status' method mentioned above.
  2. Based on the response from the method above, either load your other tracking scripts as usual or otherwise opt the visitor out.
  3. The 'Get privacy consent status' method is available on all pages with the HubSpot tracking code, so you can use it anywhere your tracking code is present.

The reference doc above has more specific technical details on how exactly the 'Get privacy consent status' method works. You'll likely also find the following documentation helpful:

Remove cookies

_hsq.push(['revokeCookieConsent']); - Remove the cookies created by the HubSpot tracking code that are included in the consent banner under GDPR.


0 Votes
cbaumert
Contributeur

Issues in Hubspot customized tracking code

We have a problem: While the cookie banner is displayed, it will not block all the site's advanced scripts that potentially collect user data. Only when the user has given his consent (s) through an active action, such as setting check marks in the banner or clicking on a button, the data processing requiring consent may actually take place (ensured by technical measures).

0 Votes
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Issues in Hubspot customized tracking code

Hi @osamanaseem,

When I navigate to your site and accept the cookie banner, the HubSpot tracking code fires just fine. What issue specifically are you seeing? I'm having trouble reproducing the issue you're describing.

It's also important to note that the tracking code does a lot more than just track webpage visits; the script manages the messages and lead flows tools as well. Visitors that opt out of cookies won't be able to use those features, since you're not loading the tracking script at all.

The recommended solution is to use the default HubSpot banner, and take advantage of the 'Get privacy consent status' method of the Tracking Code API to manage consent for your other tracking codes (i.e. GA). This would enable you to take full advantage of the HubSpot tracking code and related features, while still managing your consent for GA:

0 Votes
Non applicable

Issues in Hubspot customized tracking code

Hi @Derek_Gervais
Thanks for the reply.

Please see the attached screenshot for better understanding.

You will notice that after May (Once we start taking consent and make changes in trackign code) traffic dropped significantly. That means Hubpost is not showing all the traffic even visitor clicked on "I agreed" button.

Unfortunately I (and our dev) don't know how to implement your suggested solution. Is there any video or detailed article which can explain the above mentioned solution.

Kindly help us in implement it properly.

Thanks

0 Votes
Non applicable

Issues in Hubspot customized tracking code

Hi @Derek_Gervais
Just like to ask from you that did you get any chance to see the customized code which I shared above.
Looking forward for your expert advice.
Thanks

0 Votes
Non applicable

Issues in Hubspot customized tracking code

Hi @Derek_Gervais Thanks for the reply.

We are not using Hubspot cookie banner for consent Because it doesn't includes Google Analytics tracking. We want to get such a consent which allows both GA and hubspot codes to trigger at the same time.
Our Google analytics customized code is now working fine i.e. it triggers when visitor clicks on "I agreed" button But Hubspot customized code is not working fine.

Let me share the hubspot customized tracking code here which we are using. See bellow

var hsScript = document.createElement("script");
hsScript.type = "text/javascript";
hsScript.id = "hs-script-loader";
hsScript.src = "//js.hs-scripts.com/2937299.js";
hsScript.setAttribute("async", "");
hsScript.setAttribute("defer", "");
headElement.appendChild(hsScript);

(Line 168 to 174 in page source of www.ascertia.com)
Can you please take a look and guide about the changes which are required for this code to get triggered.
Thanks in advance.

0 Votes
Derek_Gervais
Ancien salarié HubSpot
Ancien salarié HubSpot

Issues in Hubspot customized tracking code

Hi @osamanaseem,

By default, the HubSpot tracking code won't begin tracking visitors without consent. The default cookie banner collects that consent, which then allows the tracking code to place cookies and begin tracking. The Tracking Code API also has custom methods that allow you to check a visitor's consent status in order to allow/disallow 3rd party tracking codes from running; this is the preferred method for tracking consent on HubSpot pages / when using the HubSpot tracking code. I've included some docs below for more info.

With regard to your current situation; how exactly are you customizing the HubSpot tracking code? Outside of the Tracking Code API (see below), we don't support any customization of the tracking code itself. In order to understand what's wrong with the existing behavior I'll need to understand any changes made.

https://developers.hubspot.com/docs/methods/tracking_code_api/tracking_code_overview

0 Votes