Using Google Analytics with Anvil apps

Hey, have searched the docs and forum for this answer but can’t find anything!

Is it possible to use google analytics with Anvil apps? If so, any tips on how I would do that?


1 Like

Hey Mattsibbs, you should be able to just put that in as custom HTML. You will need a paid account to do custom HTML though I believe.

Just click the edit button:

Then pop the analytics towards the top of the file

1 Like

We also have support (in beta) for analytics. Email us to get it turned on for your account.

(For Google Analytics, @chrislarge305 is exactly right. For extra points, make it a Custom HTML custom component, with methods for triggering GA events.)

Thanks @chrislarge305!

@meredydd Do you mean create a custom HTML form, put the ga script on that, make it a component, drop it onto other forms as a custom component, and somehow hook up the onShow event of the custom html form to the ga script?

@mattstibbs Yes, exactly - except you don’t even need to mess with the show event! (The Google Analytics JS will execute as soon as the component is added to the page.)

Nice thanks! Will give that a go

When using a Custom HTML component on a dashboard layout, where would you add the component? I am making heavy use of the clear / add_component paradigm:


The options I can see are:

  • Add the custom form in addition to selected form every time I add add_components to the content_panel
  • Drop the custom HTML component onto the bottom of every form I build
  • Drop the custom HTML component onto the main Dashboard form (e.g. as a menu item or on the header bar or something)

I’m not sure how these different options might affect the implementation / they way it reports so any tips welcome!

I couldn’t find anything related to analytics in the reference or in the services. Is this still a thing or should I just use GA?

As it’s a beta feature you’ll need to message @meredydd, @daviesian or @shaun and ask to be added.

Beta features normally don’t get mentioned in the general forum, but as @meredydd mentioned it above I assume it’s ok to do so.

1 Like

@joinlook it’s still in beta, I’ll get you an invite.

1 Like

Is there any info about getting started with segment on anvil?

I tried importing analytics per the instructions, but it said it was not found.

@shaun can I try out segment as well? Thanks!

@lucas.durand that’s enabled for you, enjoy!

(Aside: regarding @joinlook’s issue, we solved it in a DM - be warned that analytics.identify returns None, which is not at all obvious from Segment’s docs!)

1 Like

Hi. I’d be interest in an invite to too.

Hi, I’d be interested in an invite too!

Hi @shaun I wanted to ask you, if still possible, to try “ Segment. io".
I also wanted to ask you if you can insert Google Analytics from html document with the free plan or with the other methods suggested by Google.
Thank you in advance, have a nice day

Hi @antanineiboschi123 and Welcome to the forum.

If you use the search bar at the top of the forum you should be able to find a few posts on Segment including this link

Segment is a fantastic tool that you can then pipe data into a whole load of services. You should have a look at, it is super easy to create a range of dashboards to track how your users are interacting with your app.