Remove cookie consent banner

I am implementing Adsense and Google automatically injects me its own Cookie consent banner. I would like to make the Wasp CookieConsentBanner from the OpenSaas template not to appear.
No description
16 Replies
kapa.ai
kapa.ai7d ago
Hi @NEROX. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- I apologize, but I don't have enough specific information in the provided knowledge sources to directly answer how to remove the CookieConsentBanner from the OpenSaaS template in Wasp. The documents don't contain details about this particular component or how to disable it. However, I can provide some general guidance based on typical React and Wasp practices: 1. Look for the CookieConsentBanner component in your project files, likely in the src/client directory. 2. You might be able to conditionally render the banner or simply remove its import and usage from your main layout or App component. 3. If you need more customization options for components like this, you might be interested in an ongoing effort to make Wasp's components more flexible. There's an open issue about this: GitHub Issue #1617 (https://github.com/wasp-lang/wasp/issues/1617). If you need more specific help, I recommend reaching out to the Wasp community on Discord (https://discord.gg/rzdnErX) or via email at [email protected] (https://wasp-lang.dev/cdn-cgi/l/email-protection#31595871465042411c5d505f561f555447) as mentioned in the contact documentation (https://wasp-lang.dev/docs/contact). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP7d ago
Solved✅
No description
NEROX
NEROXOP6d ago
Unsolved again❌ I have lost Analytics tracking, I have reverted changes.
No description
No description
NEROX
NEROXOP6d ago
@kapa.ai How can I remove the cookieConsentBanner without losing my Analytics tracking. The analytics script must run everytime
kapa.ai
kapa.ai6d ago
Let me check the knowledge base for you again. One moment! :books: ---------------------- I apologize, but I don't have specific information in the provided knowledge sources about removing the cookieConsentBanner while maintaining analytics tracking in the OpenSaaS template for Wasp. The documents don't contain details about this particular component or how to modify it. However, based on general web development practices, here are some suggestions: 1. You might be able to modify the cookieConsentBanner component to always consider consent as given, allowing the analytics script to run every time. 2. Alternatively, you could look into separating the analytics script from the cookie consent logic, ensuring it runs independently. 3. If you're using Google Analytics, you might want to look into their "cookieless" tracking options, which don't require user consent. For more specific guidance on implementing these changes in your Wasp project, I recommend: 1. Checking the Wasp documentation for any relevant information about customizing components or handling analytics. 2. Reaching out to the Wasp community on Discord (https://discord.gg/rzdnErX) for more tailored assistance. 3. If you're using the OpenSaaS template, you might want to look at its documentation or repository for any specific instructions on customizing components like the cookieConsentBanner. Remember, when making changes to consent and tracking mechanisms, ensure you're complying with relevant privacy laws and regulations in your jurisdiction. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @NEROX, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
NEROX
NEROXOP6d ago
Idk, doesnt track anaytics https://toograded.com/
No description
martinsos
martinsos6d ago
@NEROX here are our docs on it: https://docs.opensaas.sh/guides/cookie-consent/ . I believe you need to delete appropriate files. As for analytics not working -> hm are they relying on Cookie consents in some way @Vinny (@Wasp) ? Do I remember correctly that Cookie consent is the one that injects google analytics script into webpage? Meaning, if you don't have cookie consent anymore, you should manually add google analytics script to the index.html (probably via app.head in main.wasp.
OpenSaaS.sh
Cookie Consent Modal
Open SaaS is a free, open-source, full-stack SaaS starter kit for React + NodeJS.
martinsos
martinsos6d ago
Yeah, it actually says here that on cookie acceptance we inject GA analytics script: https://docs.opensaas.sh/guides/cookie-consent/ . SO yeah, if you are dropping cookie consent but want to have GA analytics, you have to add it yourself, the script.
OpenSaaS.sh
Cookie Consent Modal
Open SaaS is a free, open-source, full-stack SaaS starter kit for React + NodeJS.
NEROX
NEROXOP6d ago
Will check, this file form cookie config.ts, i think is the reponsible
NEROX
NEROXOP6d ago
No description
martinsos
martinsos6d ago
yeah, insertion happens in onAccept callback you now need to do that manually probably just copy that code to main.wasp under app.head The script code, so something like <script ....
NEROX
NEROXOP6d ago
oh yeahh, just adding 2 lines. Solved✅ Edit: ❌But it only tracks the first page, trying to solve that
No description
NEROX
NEROXOP6d ago
✅ Solved, now is tracking each page (and tested) Adding to App.tsx :
declare global {
interface Window {
gtag: (
type: string,
action: string,
params: {
page_path?: string;
page_title?: string;
page_location?: string;
[key: string]: any;
}
) => void;
}
}
declare global {
interface Window {
gtag: (
type: string,
action: string,
params: {
page_path?: string;
page_title?: string;
page_location?: string;
[key: string]: any;
}
) => void;
}
}
Adding to main.wasp:
"<script async src=\"https://www.googletagmanager.com/gtag/js?id=XXXXXXXX\"></script>",
"<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag(\"js\",new Date());gtag(\"config\",\"G-XXXXXXXX\",{send_page_view:false});</script>"
"<script async src=\"https://www.googletagmanager.com/gtag/js?id=XXXXXXXX\"></script>",
"<script>window.dataLayer=window.dataLayer||[];function gtag(){dataLayer.push(arguments);}gtag(\"js\",new Date());gtag(\"config\",\"G-XXXXXXXX\",{send_page_view:false});</script>"
And creating a usePageTracking.ts:
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export const usePageTracking = () => {
const location = useLocation();

useEffect(() => {
if (typeof window.gtag !== 'undefined') {
window.gtag('event', 'page_view', {
page_path: location.pathname + location.search,
page_title: document.title,
page_location: window.location.href
});
}
}, [location]);
};
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

export const usePageTracking = () => {
const location = useLocation();

useEffect(() => {
if (typeof window.gtag !== 'undefined') {
window.gtag('event', 'page_view', {
page_path: location.pathname + location.search,
page_title: document.title,
page_location: window.location.href
});
}
}, [location]);
};
No description
Vinny (@Wasp)
Vinny (@Wasp)5d ago
Do you think we should add an issue to update the docs with this info in the case they don't want to use the cookie consent modal? Or just let them figure it out themselves
NEROX
NEROXOP5d ago
Julius Fedorovicius
Analytics Mania
Track Single Page Apps with Google Analytics 4 and Google Tag Manager
Learn how to track Single Page App with Google Tag Manager (or Single Page Website), and send that pageview data to Google Analytics.
martinsos
martinsos5d ago
Thanks, added link to our SEO issue for Wasp to take into condiseration Hm yeah I tihnk we should!
Want results from more Discord servers?
Add your server