2
votes

I have implemented Firebase in my iOS app. Also I have added Google Tag Manager, I followed these instructions:

Data is send to Firebase because I see the event I am sending popup in Firebase Analytics. However, it does not seem to trigger Google Tagmanager. Google Tagmanager is setup to trigger Google Analytics, which also is not happening.

When I try the preview URL in the simulator I get the following error in the logs:

2016-06-30 10:33:37.592 MyApp[58890:] <FIRAnalytics/DEBUG> Deep Link does not contain valid required params. URL params: {
        "gtm_auth" = "lmsB-*****************";
        "gtm_preview" = 2;
        id = "GTM-XXXXXX";
    }

However, I use the container id com.myapp.app which is correct both for the container but as well for the urlscheme in the app as well as the app bundle id.

This is my code:

extension AppDelegate: ApiManagerDelegate {

    func didRecieveGTMData(data: AnyObject) {
        if let objects = data as? [[String:AnyObject]] {
            for event in objects {
                if let
                    event = event as? [String:NSObject],
                    name = event["event"] as? String {
                    FIRAnalytics.logEventWithName(name, parameters: event)

                    AppLog("Sending event \(name) to TagManager", logType: .Warning)
                }
            }
        }
    }

}

This is my log, with debug enabled.

2016-06-30 10:59:51.875: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
"1467284391.876531: application(_:didFinishLaunchingWithOptions:) - APPS: Optional([__FIRAPP_DEFAULT: <FIRApp: 0x7f916b860dc0>])"
2016-06-30 10:59:51.897 MyApp[63243:] <FIRAnalytics/DEBUG> Debug mode is on
2016-06-30 10:59:51.898 MyApp[63243:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-06-30 10:59:51.899 MyApp[63243:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http:// goo.gl/Y0Yjwu)
2016-06-30 10:59:51.899 MyApp[63243:] <FIRAnalytics/DEBUG> Debug logging enabled
2016-06-30 10:59:51.900 MyApp[63243:] <FIRAnalytics/DEBUG> Firebase Analytics is monitoring the network status
2016-06-30 10:59:51.904 MyApp[63243:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
2016-06-30 10:59:51.919 MyApp[63243:] <FIRAnalytics/DEBUG> Successfully parsed a configuration. Version: 1462963036106000
2016-06-30 10:59:51.961 MyApp[63243:] <FIRAnalytics/DEBUG> Firebase Analytics is ready to receive events
2016-06-30 10:59:51.966 MyApp[63243:] <FIRAnalytics/DEBUG> No data to upload. Upload task will not be scheduled
2016-06-30 10:59:51.967 MyApp[63243:] <FIRAnalytics/DEBUG> Cancelling background upload task.
2016-06-30 10:59:51.967 MyApp[63243:] <FIRAnalytics/DEBUG> Scheduling user engagement timer
2016-06-30 10:59:51.967 MyApp[63243:] <FIRAnalytics/DEBUG> Timer scheduled to fire in approx. (s): 3600
2016-06-30 10:59:51.968 MyApp[63243:] <FIRAnalytics/INFO> Firebase Analytics enabled
2016-06-30 10:59:52.162 MyApp[63243:] <FIRAnalytics/DEBUG> Network status has changed. code, status: 2, Connected
2016-06-30 10:59:52.163 MyApp[63243:] <FIRAnalytics/DEBUG> Network status has changed. code, status: 2, Connected
2016-06-30 10:59:52.206 MyApp[63243:] <FIRAnalytics/DEBUG> Received SSL challenge for host. Host: https://play.googleapis.com/log
2016-06-30 10:59:52.458 MyApp[63243:] <FIRAnalytics/DEBUG> Uploading data. Host: https://play.googleapis.com/log
2016-06-30 10:59:52.505 MyApp[63243:] <FIRAnalytics/DEBUG> Received SSL challenge for host. Host: https://play.googleapis.com/log

"⚠️ 1467284414.833250: didRecieveGTMData - Sending event conversionTracking to TagManager"

2016-06-30 11:00:14.856 MyApp[63243:] <FIRAnalytics/DEBUG> Logging event: origin, name, params: app, conversionTracking, {
        "VAR_USER_ID" = 0;
        "_o" = app;
        event = conversionTracking;
        eventAction = Signup;
        eventCategory = Conversion;
        eventId = signup;
        eventLabel = Success;
        eventStatus = success;
        forAffiliates = 1;
        geoCountry = SE;
        nrId = 000000;
        partAccountId = Account;
        partClickId = Click;
        partId = XXXXX;
        partKeywords = Keywords;
        partMarketingId = Marketing;
        plyCountry = SE;
        plyCurrency = SEK;
    }
2016-06-30 11:00:15.009 MyApp[63243:] <FIRAnalytics/DEBUG> Event logged. Event name, event params: conversionTracking, {
        "VAR_USER_ID" = 0;
        "_o" = app;
        event = conversionTracking;
        eventAction = Signup;
        eventCategory = Conversion;
        eventId = signup;
        eventLabel = Success;
        eventStatus = success;
        forAffiliates = 1;
        geoCountry = SE;
        nrId = 000000;
        partAccountId = Account;
        partClickId = Click;
        partId = XXXXX;
        partKeywords = Keywords;
        partMarketingId = Marketing;
        plyCountry = SE;
        plyCurrency = SEK;
    }
2016-06-30 11:00:15.012 MyApp[63243:] <FIRAnalytics/DEBUG> Timer scheduled to fire in approx. (s): 1993.185952067375
2016-06-30 11:00:15.012 MyApp[63243:] <FIRAnalytics/DEBUG> Upload task scheduled to be executed in approx. (s): 1993.185952067375
2016-06-30 11:00:17.054 MyApp[63243:] <FIRAnalytics/DEBUG> Scheduling user engagement timer
2016-06-30 11:00:17.054 MyApp[63243:] <FIRAnalytics/DEBUG> Canceling active timer
2016-06-30 11:00:17.054 MyApp[63243:] <FIRAnalytics/DEBUG> Timer scheduled to fire in approx. (s): 3600
2016-06-30 11:00:17.055 MyApp[63243:] <FIRAnalytics/DEBUG> Canceling active timer
2016-06-30 11:00:17.055 MyApp[63243:] <FIRAnalytics/DEBUG> App will resign active state. Scheduling data upload
2016-06-30 11:00:17.055 MyApp[63243:] <FIRAnalytics/DEBUG> Starting data upload
2016-06-30 11:00:17.057 MyApp[63243:] <FIRAnalytics/DEBUG> Saving bundle. size (bytes): 562
2016-06-30 11:00:17.058 MyApp[63243:] <FIRAnalytics/DEBUG> Bundle added to the upload queue. BundleID, timestamp (ms): 39, 1467277214833
2016-06-30 11:00:17.155 MyApp[63243:] <FIRAnalytics/DEBUG> Uploading events. Elapsed time since last successful upload (s): 1608.957054853439
2016-06-30 11:00:17.156 MyApp[63243:] <FIRAnalytics/DEBUG> Measurement data sent to network. Timestamp (ms), data: 1467277217155, <ACPMeasurementBatch 0x7f916beea360>: {
        bundles {
          protocol_version: 1
          events {
            params {
              name: "partId"
              string_value: "XXXXX"
            }
            params {
              name: "partKeywords"
              string_value: "Keywords"
            }
            params {
              name: "eventAction"
              string_value: "Signup"
            }
            params {
              name: "plyCurrency"
              string_value: "SEK"
            }
            params {
              name: "event"
              string_value: "conversionTracking"
            }
            params {
              name: "partMarketingId"
              string_value: "Marketing"
            }
            params {
              name: "eventStatus"
              string_value: "success"
            }
            params {
              name: "partAccountId"
              string_value: "Account"
            }
            params {
              name: "partClickId"
              string_value: "Click"
            }
            params {
              name: "forAffiliates"
              int_value: 1
            }
            params {
              name: "plyCountry"
              string_value: "SE"
            }
            params {
              name: "eventLabel"
              string_value: "Success"
            }
            params {
              name: "VAR_USER_ID"
              string_value: "0"
            }
            params {
              name: "nrId"
              string_value: "000000"
            }
            params {
              name: "eventId"
              string_value: "signup"
            }
            params {
              name: "_o"
              string_value: "app"
            }
            params {
              name: "eventCategory"
              string_value: "Conversion"
            }
            params {
              name: "geoCountry"
              string_value: "SE"
            }
            name: "conversionTracking"
            timestamp_millis: 1467277214833
            previous_timestamp_millis: 1467273532697
          }
          user_attributes {
            set_timestamp_millis: 1465483501262
            name: "_fot"
            int_value: 1465484400000
          }
          upload_timestamp_millis: 1467277217155
          start_timestamp_millis: 1467277214833
          end_timestamp_millis: 1467277214833
          previous_bundle_end_timestamp_millis: 1467275607927
          platform: "ios"
          os_version: "9.2"
          device_model: "x86_64"
          user_default_language: "en-us"
          time_zone_offset_minutes: 120
          app_store: "manual_install"
          app_id: "com.casinoroom.app"
          app_version: "2.0"
          gmp_version: 3200
          uploading_gmp_version: 3200
          resettable_device_id: "0A4F72DB-4790-4227-899B-463730BC3DA1"
          limited_ad_tracking: false
          app_instance_id: "DF4F87E8B6EB41F497C88995F9E7FE7A"
          bundle_sequential_index: 39
          gmp_app_id: "1:98619240432:ios:e648ebe381ed4c52"
          previous_bundle_start_timestamp_millis: 1467275607927
          firebase_instance_id: "dtPuhg5zGEo"
          app_version_major: 234
        }
    }
2016-06-30 11:00:17.157 MyApp[63243:] <FIRAnalytics/DEBUG> Uploading data. Host: https://app-measurement.com/a
2016-06-30 11:00:17.158 MyApp[63243:] <FIRAnalytics/DEBUG> Logging event: origin, name, params: auto, _e, {
        "_et" = 25056;
        "_o" = auto;
    }
2016-06-30 11:00:17.204 MyApp[63243:] <FIRAnalytics/DEBUG> Received SSL challenge for host. Host: https://app-measurement.com/a
2016-06-30 11:00:17.255 MyApp[63243:] <FIRAnalytics/DEBUG> Event logged. Event name, event params: _e, {
        "_et" = 25056;
        "_o" = auto;
    }
2016-06-30 11:00:17.355 MyApp[63243:] <FIRAnalytics/DEBUG> Do not schedule an upload task. Task already exists
2016-06-30 11:00:17.356 MyApp[63243:] <FIRAnalytics/DEBUG> Successful upload. Got network response. Code, size: 204, 0
2016-06-30 11:00:17.356 MyApp[63243:] <FIRAnalytics/DEBUG> Do not schedule an upload task. Task already exists
2016-06-30 11:00:17.357 MyApp[63243:] <FIRAnalytics/DEBUG> Starting data upload
2016-06-30 11:00:17.358 MyApp[63243:] <FIRAnalytics/DEBUG> Saving bundle. size (bytes): 309
2016-06-30 11:00:17.359 MyApp[63243:] <FIRAnalytics/DEBUG> Bundle added to the upload queue. BundleID, timestamp (ms): 40, 1467277217021
2016-06-30 11:00:17.359 MyApp[63243:] <FIRAnalytics/DEBUG> Uploading events. Elapsed time since last successful upload (s): 0.00379490852355957
2016-06-30 11:00:17.360 MyApp[63243:] <FIRAnalytics/DEBUG> Measurement data sent to network. Timestamp (ms), data: 1467277217359, <ACPMeasurementBatch 0x7f916f0a6020>: {
        bundles {
          protocol_version: 1
          events {
            params {
              name: "_et"
              int_value: 25056
            }
            params {
              name: "_o"
              string_value: "auto"
            }
            name: "_e"
            timestamp_millis: 1467277217021
            previous_timestamp_millis: 1467275607927
          }
          user_attributes {
            set_timestamp_millis: 1465483501262
            name: "_fot"
            int_value: 1465484400000
          }
          upload_timestamp_millis: 1467277217359
          start_timestamp_millis: 1467277217021
          end_timestamp_millis: 1467277217021
          previous_bundle_end_timestamp_millis: 1467277214833
          platform: "ios"
          os_version: "9.2"
          device_model: "x86_64"
          user_default_language: "en-us"
          time_zone_offset_minutes: 120
          app_store: "manual_install"
          app_id: "com.casinoroom.app"
          app_version: "2.0"
          gmp_version: 3200
          uploading_gmp_version: 3200
          resettable_device_id: "0A4F72DB-4790-4227-899B-463730BC3DA1"
          limited_ad_tracking: false
          app_instance_id: "DF4F87E8B6EB41F497C88995F9E7FE7A"
          bundle_sequential_index: 40
          gmp_app_id: "1:98619240432:ios:e648ebe381ed4c52"
          previous_bundle_start_timestamp_millis: 1467277214833
          firebase_instance_id: "dtPuhgXXXXX"
          app_version_major: 234
        }
    }
2016-06-30 11:00:17.361 MyApp[63243:] <FIRAnalytics/DEBUG> Uploading data. Host: https://app-measurement.com/a
2016-06-30 11:00:17.404 MyApp[63243:] <FIRAnalytics/DEBUG> Received SSL challenge for host. Host: https://app-measurement.com/a
2016-06-30 11:00:17.408 MyApp[63243:] <FIRAnalytics/DEBUG> Successful upload. Got network response. Code, size: 204, 0
2016-06-30 11:00:17.409 MyApp[63243:] <FIRAnalytics/DEBUG> Do not schedule an upload task. Task already exists
2016-06-30 11:00:17.411 MyApp[63243:] <FIRAnalytics/DEBUG> No data to upload. Upload task will not be scheduled
2016-06-30 11:00:17.412 MyApp[63243:] <FIRAnalytics/DEBUG> Canceling active timer
2016-06-30 11:00:17.412 MyApp[63243:] <FIRAnalytics/DEBUG> Cancelling background upload task.

My question: What am I missing? Do I need to configure anything more? Missing something in the code?

1
Can you post your Google Tag Manager container setup? In particular what trigger(s) are you using, and how are your Google Analytics tag(s) configured?Eric Burley

1 Answers

0
votes

I followed those same instructions. What was not obvious to me was that you have to set up at least one tag in GTM (not just the variables). Creating a tag prompts you to connect to a GA account id. After I set up the tag and updated my GTM profile in my app, deleted the old app from my simulator and re-ran it, I see this type of output in the logs, now referencing my GA account id, which it did not before. And indeed, in realtime I see the events flowing through to Analytics.

2017-10-18 15:24:01.270736-0600 HelloAnalytics[11786:1427214] GoogleTagManager info: Sending universal analytics hit: {
"&ea" = "_vs";
"&ec" = HelloAnalytics;
"&ni" = 0;
"&t" = event;
"&tid" = "UA-XXXXXXXXX-1";

}