astro-analytics icon indicating copy to clipboard operation
astro-analytics copied to clipboard

Unexpected Amplitude snipped included along with Google Analytics

Open iron-cherep opened this issue 2 years ago • 5 comments

Issue:

When using Google Analytics through astro-analytics, an unexpected Amplitude Analytics snippet is also being included

Repo with reproduction:

Included Google Analytics component: https://github.com/iron-cherep/astro-analytics-repro/blob/23314b745c3af5c326851746441d03e2b353ef47/src/pages/index.astro#L16

Amplitude snippet in resulting build: https://github.com/iron-cherep/astro-analytics-repro/blob/23314b745c3af5c326851746441d03e2b353ef47/dist/index.html#L9

iron-cherep avatar May 31 '23 11:05 iron-cherep

I tried to check the code, but I cannot see why this snippet is being included. But this is kind of breaking the Google Pagespeed score as well 😅

I will try to dig a little deeper tonight see if I can fix it.

nlxdodge avatar Aug 25 '23 14:08 nlxdodge

Same issue for me. I am trying to use the Umami component but I see Amplitude errors in console and network tab on website. Not sure why it is being included by default.

aemmadi avatar Sep 13 '23 14:09 aemmadi

I checked it a while ago, it seems like the original JavaScript code from Amplitude auto injects itself in some way. But this would mean every time an update comes out, that we need to manually edit the code that they use if we try to change it our-self.

Eventually I switched away from astro-analytics, as this cannot be solved without modifying the code from Amplitude itself.

nlxdodge avatar Oct 11 '23 11:10 nlxdodge

I tried importing the analytics directly from src/foo.astro but it wouldnt let me. The problem arises because the index.ts imports / exports all astro components. If we could import the component we need directly, it would work

Fuzzyma avatar Oct 24 '23 07:10 Fuzzyma

same issue , when i want to use only google analytics and i had an error on the console that i miss an api key for amplitude ice_screenshot_20231124-142502

mahdisoultana avatar Nov 24 '23 13:11 mahdisoultana