0
0
Firebasecloud~10 mins

Google Analytics integration in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to initialize Firebase Analytics in your app.

Firebase
const analytics = getAnalytics([1]);
Drag options to blanks, or click blank then click option'
Aapp
Bfirebase
Canalytics
Dconfig
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the wrong variable like 'firebase' or 'config' instead of the app instance.
Not passing any argument to getAnalytics.
2fill in blank
medium

Complete the code to log a custom event named 'purchase' with Firebase Analytics.

Firebase
logEvent(analytics, [1], { value: 100 });
Drag options to blanks, or click blank then click option'
A'login'
B'click'
C'purchase'
D'signup'
Attempts:
3 left
💡 Hint
Common Mistakes
Using an unrelated event name like 'login' or 'click'.
Forgetting to put the event name in quotes.
3fill in blank
hard

Fix the error in the code to import Firebase Analytics correctly.

Firebase
import { [1] } from 'firebase/analytics';
Drag options to blanks, or click blank then click option'
AinitializeAnalytics
BgetAnalytics
CfirebaseAnalytics
DanalyticsInit
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names like 'initializeAnalytics' or 'analyticsInit'.
Trying to import a default export instead of a named export.
4fill in blank
hard

Fill both blanks to configure Firebase Analytics with your app and enable analytics collection.

Firebase
const analytics = getAnalytics([1]);
setAnalyticsCollectionEnabled(analytics, [2]);
Drag options to blanks, or click blank then click option'
Aapp
Bfalse
Ctrue
DfirebaseApp
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 'false' to disable analytics collection.
Using an incorrect variable name for the app instance.
5fill in blank
hard

Fill all three blanks to log a 'level_up' event with level number and character name.

Firebase
logEvent(analytics, [1], { level: [2], character: [3] });
Drag options to blanks, or click blank then click option'
A'level_up'
B5
C'wizard'
D'game_start'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong event names like 'game_start'.
Not quoting string values properly.
Passing level as a string instead of a number.