-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work #3
Comments
Same issue, can't make it work, can you provide a working example ? thanks |
Correct, the plugin seems to suck. For anyone trying to use Cookiehub see the gatsby docs for adding the script inline: https://www.gatsbyjs.org/docs/custom-html/#adding-custom-javascript Finally got it working. |
The plugin didn't work for me too and I don't want to integrate cookiehub using Now, I integrated cookiehub with my own react component: import React from "react"
import Helmet from 'react-helmet';
const CookieBannerCookieHub = ({ googleTrackingId, cookieHubId }) => {
const googleUrl = "https://www.googletagmanager.com/gtag/js?id=" + googleTrackingId
const cookieHubUrl = "https://cookiehub.net/cc/" + cookieHubId + ".js"
return (
<Helmet
script={[
{
type: "text/javascript",
src: googleUrl
},
{
type: "text/javascript",
innerHTML:
`var gtagId = '`+googleTrackingId+`';
window['ga-disable-' + gtagId] = true;
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments)}
gtag('js', new Date());`
},
{
type: "text/javascript",
src: cookieHubUrl
},
{
type: "text/javascript",
innerHTML:
`window.addEventListener("load", function() {
window.cookieconsent.initialise({
onInitialise: function(status) {
if (this.hasConsented('required')) {
}
if (this.hasConsented('analytics')) {
window['ga-disable-`+googleTrackingId+`'] = false;
gtag('config', gtagId);
}
if (this.hasConsented('marketing')) {
}
},
onAllow: function(category) {
if (category == 'required') {
}
if (category == 'analytics') {
window['ga-disable-`+googleTrackingId+`'] = false;
gtag('config', gtagId);
}
if (category == 'marketing') {
}
},
onRevoke: function(category) {
if (category == 'required') {
}
if (category == 'analytics') {
window['ga-disable-`+googleTrackingId+`'] = true;
}
if (category == 'marketing') {
}
}
})
});`
}
]}
/>
)
}
export default CookieBannerCookieHub Within <CookieBannerCookieHub googleTrackingId="<YOUR TRACKING ID>" cookieHubId="<YOUR COOKIEHUB ID>"/> I published this small component: https://github.com/VirtualFox0/react-cookiehub-banner |
No cookiehub scripts added, you do not even use cookieshub in your own website, nor any other cookie compliance scripts.
All the starters that say they use this do not and why not.
Working example of your work is needed, but no one does that anymore and that really a problem with the whole internet programming community.
Show me!
The text was updated successfully, but these errors were encountered: