Comments (5)
If you can add a script inside the iframe I think you could do something like:
window.ga = function() { galite.apply(galite, arguments) }
This should proxy all ga
calls to galite
.
I can double check when I'm on computer if that doesn't work 😄
from ga-lite.
Awesome! I'm trying to figure out how to add the script to the iFrame at the moment. I'll let you know how it turns out. That definitely works for ga calls outside of the iFrame. Thanks!
from ga-lite.
I'm having no luck with this. The code you gave me above works perfectly in the main window, but I'm unable to get it to do anything in the iFrame. The iframe is being pieced together from their 3rd party script, which is minified, but pretty printing it, this is the code that I find in the script referring to GTM. It looks like if the source is 'https://www.googletagmanager.com/gtm.js', then use that, else break. Below is that code. Any guidance would be appreciated!
ge), be = K(["\nmutation track($userId: String!, $event: String!, $properties: [String]) {\n track(userId: $userId, event: $event, properties: $properties) {\n status\n }\n}\n"]), we = {
WEBSITE_WIDGET_CLOSE: "Widget Closed",
WEBSITE_WIDGET_OPEN: "Bubble Clicked",
WEBSITE_WIDGET_SENT: "Conversation Started"
}, _e = "Webchat Widget", Se = null, Ce = function e(t) {
var n = window[window.PodiumGTMDataLayerMapping] || window.dataLayer
, r = fe();
if (n) {
var o = {
event: _e,
eventCategory: "podium",
eventAction: t,
eventLabel: "WIDGET-TOKEN:".concat(r)
};
n.push(o)
} else if (!Se) {
var i = document.getElementsByTagName("script")
, a = "";
for (var u in i) {
var s = i[u];
if (R(s.src, "https://www.googletagmanager.com/gtm.js")) {
a = s.src;
break
}
}
if (a) {
var c = new URLSearchParams(a).get("l");
c ? (window.PodiumGTMDataLayerMapping = c,
e(t)) : Se = !0
} else
Se = !0
}
},
xe = function(e) {
var t = window.ga || window[window.GoogleAnalyticsObject],
n = t && t.getAll && t.getAll();
t ? I(n, (function(t) {
return t.send("event", _e, e)
})) : t ? t("send", "event", _e, e) : O((function() {
return window._gaq.push
})) && window._gaq.push(["_trackEvent", _e, e])
},
ke = function(e) {
window.fbq && window.fbq("trackCustom", _e, e)
},
Ne = function(e) {
window.pintrk && window.pintrk("track", "custom", {
type: _e,
event: e
})
},
from ga-lite.
Hmm. Depending on if the iframe's content security policy you might be able to inject stuff to it by using something like:
var myIframe = document.getElementById('my-iframe') // or some other way to target the third-party iframe
var doc = myIframe.contentWindow.document
// Insert ga-lite
var galiteScript = doc.createElement("script")
galiteScript.src = "https://cdn.jsdelivr.net/npm/ga-lite@2/dist/ga-lite.min.js"
doc.body.appendChild(galiteScript)
// add ga-lite proxy
var script = doc.createElement("script")
script.innerHTML = 'window.ga = function() { galite.apply(galite, arguments) }'
doc.body.appendChild(script)
from ga-lite.
I appreciate it @jehna! Will try it out this evening and let you know.
from ga-lite.
Related Issues (20)
- Support for the new Google Analytics 4 tag HOT 9
- Use keepalive flag with fetch
- Add note to README about using preconnect/preload to improve google page speed HOT 7
- ESM version for modern browsers HOT 10
- Universal Analytics (GA3) and GA4 same time HOT 2
- Illegal Invocation error due to lack of navigator.sendBeacon binding HOT 1
- Self Referral Traffic
- NPM bundle not including commands directory HOT 1
- Customizable endpoint URL and User Language HOT 2
- Instructions on using esm version to readme HOT 4
- SyntaxError Unexpected token = HOT 2
- Yarn run build not working HOT 4
- XMLHttpRequest on main thread is deprecated HOT 2
- Are Conversion Tags Possible & Phone Number Tags HOT 4
- Disableing of ga-lite through cookie HOT 4
- SSR issue introduced HOT 5
- It should be mentioned that ga-lite doesn't use cookies HOT 3
- Stop working on Chrome 85+ for somehow HOT 6
- Test coverage for SSR / node.js compatibility HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ga-lite.