Samouczek: pomiar konwersji w Google Ads

Krok 1. Wdróż logowanie


Wprowadzenie: Pomiar konwersji z reklam na iOS

Krok 1. Wdróż logowanie

Krok 2: Zintegruj Google Analytics
Krok 3: Zainicjuj pomiar konwersji na urządzeniu za pomocą Google Analytics
Krok 4. Rozwiązywanie typowych problemów


Pierwszym krokiem jest wdrożenie funkcji logowania, która umożliwi użytkownikom podawanie adresów e-mail lub numerów telefonów.

Używany system uwierzytelniania musi podawać adres e-mail lub numer telefonu powiązany z użytkownikiem. Poniższe kroki opisują proces bezpiecznego zbierania informacji o logowaniu za pomocą Firebase Authentication. Możesz jednak pominąć ten krok, jeśli masz już system uwierzytelniania, który zbiera adresy e-mail lub numery telefonów użytkowników, i przejść do kroku 2: integracja Google Analytics.

Konfigurowanie systemu uwierzytelniania

Używanie metody logowania Firebase Authentication

Możesz użyć Firebase Authentication, aby umożliwić użytkownikom logowanie się w aplikacji za pomocą co najmniej 1 metody logowania, w tym adresu e-mail, numeru telefonu, hasła i dostawców tożsamości sfederowanej (takich jak Google, Facebook czy Twitter). Zapoznaj się z artykułem Pierwsze kroki w Firebase Authentication.

Integracja Firebase Authentication z niestandardowym systemem uwierzytelniania

Możesz też zintegrować Firebase Authentication z niestandardowym systemem uwierzytelniania, modyfikując serwer uwierzytelniania, aby generował niestandardowe podpisane tokeny, gdy użytkownik zaloguje się. Aplikacja otrzymuje ten token i używa go do uwierzytelniania w Firebase. Zapoznaj się z artykułem Pierwsze kroki z niestandardowym systemem uwierzytelniania.

Uzyskiwanie adresu e-mail lub numeru telefonu uwierzytelnionego użytkownika

Po skonfigurowaniu systemu uwierzytelniania za pomocą Firebase Authentication możesz uzyskać informacje o obecnie zalogowanym użytkowniku.

Zalecanym sposobem uzyskania informacji o bieżącym użytkowniku jest ustawienie odbiornika na obiekcie Auth:

Swift

handle = Auth.auth().addStateDidChangeListener { auth, user in
  // Get the user's email address
  let email = user.email
  // or get their phone number
  let phoneNumber = user.phoneNumber
  // ...
}

Objective-C

self.handle = [[FIRAuth auth]
  addAuthStateDidChangeListener:^(FIRAuth *_Nonnull auth, FIRUser *_Nullable user) {
    // Get the user's email address
    NSString *email = user.email;
    // or get their phone number
    NSString *phoneNumber = user.phoneNumber;
    // ...
  }];

Unity

Firebase.Auth.FirebaseAuth auth;
Firebase.Auth.FirebaseUser user;

// Handle initialization of the necessary firebase modules:
void InitializeFirebase() {
  auth = Firebase.Auth.FirebaseAuth.DefaultInstance;
  auth.StateChanged += AuthStateChanged;
  AuthStateChanged(this, null);
}

// Track state changes of the auth object.
void AuthStateChanged(object sender, System.EventArgs eventArgs) {
  if (auth.CurrentUser != user) {
    bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null;
    user = auth.CurrentUser;
    if (signedIn) {
      // Get the user's email address
      string email = user.Email;
      // or get their phone number
      string phoneNumber = user.PhoneNumber;
      // ...
    }
  }
}

// Handle removing subscription and reference to the Auth instance.
// Automatically called by a Monobehaviour after Destroy is called on it.
void OnDestroy() {
  auth.StateChanged -= AuthStateChanged;
  auth = null;
}




Wprowadzenie Krok 2. Integracja Google Analytics