         setupTextFields()
         getMailboxSettings()
         self.tableView.addSubview(self.refreshControl)
+        GAEvents.event(category: ga_tag, action: "åpne-view", label: "mappevisning", value: nil)
+    }
+    
+    override func viewWillDisappear(_ animated: Bool) {
+        super.viewWillDisappear(animated)
+        var saveState = "Lagre ikke"
+        if saveButtonPressed && actuallySaved {
+            saveState = "Lagret og fullførte vellykket"
+        }else if saveButtonPressed {
+            saveState = "Lagret, men feilet"
+        }
+        GAEvents.event(category: ga_tag, action: "lukke-view", label: saveState, value: nil)
     }
     
     @objc func handleRefresh(_ refreshControl: UIRefreshControl) {

                POSRootResource.existingRootResource(in: POSModelManager.shared().managedObjectContext) {
                if let mailboxSettingsUri = rootResource.mailboxSettingsUri {
                    APIClient.sharedClient.updateMailboxSettings(uri: mailboxSettingsUri,mailboxSettings: mailboxSettings ,success: {() -> Void in
                        self.finish()
                    }, failure: ({_ in
                        self.showAlertMessage(title: NSLocalizedString("error_contact_info_title", comment: ""), text: NSLocalizedString("error_contact_info_message", comment: ""))
                    }))
                }
            }
        } else{
            self.showAlertMessage(title: NSLocalizedString("invalid_email_title", comment: "invalid email"), text: NSLocalizedString("invalid_email_message", comment: "Please check"))
        }
    }

                var newEmail = [String: Any]()
                newEmail["email"] = emailAddress
                emails.append(newEmail)
                GAEvents.event(category: ga_tag, action: "e-post", label: "legger til ny", value: nil)
            }else{
                if emailAddress.isEmpty {
                    GAEvents.event(category: ga_tag, action: "e-post", label: "fjerner eksisterende", value: nil)
                }else{
                    GAEvents.event(category: ga_tag, action: "e-post", label: "oppdaterer eksisterende", value: nil)
                }
                emails[index].updateValue(emailAddress, forKey: "email")
            }
        }
        updateEmailView(emailView: sender, email: emailAddress)
    }
    
    func updatePhonenumber(new: String) {
        let old = (self.mobilePhoneNumber["phoneNumber"] as! String)
        
        if old.isEmpty && !new.isEmpty{
            GAEvents.event(category: ga_tag, action: "telefonnummer", label: "legger til nytt", value: nil)
        }else if !old.isEmpty && new.isEmpty {
            GAEvents.event(category: ga_tag, action: "telefonnummer", label: "fjerner eksisterende", value: nil)
        }else if !old.elementsEqual(new){
            GAEvents.event(category: ga_tag, action: "telefonnummer", label: "oppdaterer eksisterende", value: nil)
        }
        
        self.mobilePhoneNumber.updateValue(new, forKey: "phoneNumber")
    }
    
    func updateEmailView(emailView: UITextField, email: String) {
