In that snippet, you’ll find lots of mention of a configuration setting “instrumentation key”. This is the ID of the app insights instance that your data will be sent to.
The thing is, it has been deprecated in favour of “connection string”. This is the same connection string as you use server-side (as described previously), and can be read from:
string aiConnection = TelemetryConfiguration.Active?.ConnectionString;
You should do this and render the connection string rather than hard-code it into your layout page.