-
Notifications
You must be signed in to change notification settings - Fork 298
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
Question / Using google tag manager from web component does not connect to https://www.googletagmanager.com #1229
Comments
In your browser, do you see any networks requests. I don't have a google analytics account, so it's hard for me to test it out. I did try asking Claude. Here's the output. I think it could work. Basically they programmatically add the script tags to the head element. I have not tried this out, so it may work or it may not. Seems worth a try. You'll need to modify it to work with Mesop Web Components.
|
Thank you @richard-to - I was able to get the component to load, and I see one call going out to google tag manager now (I did not before, to that is progress!). I'm now stuck with gettign past an error my browser throws in the new component:
I've been experimenting with the security policy and can't quite get it to work fully: @me.page(
This tip
ℹ️ If this is coming from your web component, @me.page( For more info: does not do anything - the browser (Chrome) complains about the '://' as invalid. Do you have any tips about circumventing this issue? Thanks again for your help! |
Describe the bug
I'm trying to use google tag manager on my minimal web application. To include the tag manager js snippet, I added a web component. The web component does render on my page (the div is visible), but it does not seem to connect back to https://www.googletagmanager.com/
To Reproduce
header_component.js (backticks removed)
import {
LitElement,
html,
} from 'https://cdn.jsdelivr.net/gh/lit/dist@3/core/lit-core.min.js';
class HeaderComponent extends LitElement {
;
}
}
customElements.define('header-component', HeaderComponent);
header_component.py:
from typing import Any, Callable
import mesop.labs as mel
@mel.web_component(path="./header_component.js")
def HeaderComponent(key: str | None = None):
return mel.insert_web_component(
name="header-component",
key=key,
)
mesop app: (after many experiments)
@me.page(
path="/",
title="Integral Health Scheduling",
on_load=load,
# stylesheets=["https://www.gstatic.com/firebasejs/ui/6.1.0/firebase-ui-auth.css"],
security_policy=me.SecurityPolicy(
dangerously_disable_trusted_types=True,
allowed_connect_srcs=[".googleapis.com", "https://www.googletagmanager.com"],
allowed_script_srcs=["localhost:32123", ".google.com", "*.gstatic.com", "https://cdn.jsdelivr.net", "https://www.googletagmanager.com"],
),
)
def main():
Expected behavior
The page should invoke the tag manager API on google's side. Nothing seems to make it through. (also per the browser's network monitor)
Desktop System Info
The text was updated successfully, but these errors were encountered: