iOS Google Tag Manager crashing upon Launch with 'NSParseErrorException', reason: 'Last tag: 116 should be 124'

1.3k views Asked by At

We have Google Analytics with Google Tag Manager running in 3 of our other iOS apps but for some reason this latest app is crashing upon trying to open the container.

Here's the line of code in question (similar to GTM's guidelines):

        NSTimeInterval timeout = 0.1;
        [TAGContainerOpener openContainerWithId:containerName
                                     tagManager:_tagManager
                                       openType:kTAGOpenTypePreferNonDefault
                                        timeout:&timeout
                                       notifier:self];

The error thrown:

Terminating app due to uncaught exception 'NSParseErrorException', 
reason: 'Last tag: 116 should be 124'

Stack trace:

*** First throw call stack:
(
    0   CoreFoundation                      0x0000000104dffa75 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104716bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x0000000104dff9ad +[NSException raise:format:] + 205
    3   MyApp                             0x0000000102831ce6 -[TAGPBCodedInputStream readUnknownGroup:builder:] + 152
    4   MyApp                             0x0000000102844904 -[TAGPBUnknownFieldSet mergeFieldFrom:input:] + 283
    5   MyApp                             0x000000010283ceb1 -[TAGPBGeneratedMessage parseUnknownField:extensionRegistry:tag:] + 203
    6   MyApp                             0x000000010283cfc8 -[TAGPBGeneratedMessage mergeFromCodedInputStream:extensionRegistry:] + 264
    7   MyApp                             0x000000010283cb35 -[TAGPBGeneratedMessage mergeFromData:extensionRegistry:] + 88
    8   MyApp                             0x000000010283cc1e +[TAGPBGeneratedMessage parseFromData:extensionRegistry:] + 82
    9   MyApp                             0x0000000102852da7 -[TAGResourceStorageImpl loadResourceFromContainerFile:] + 352
    10  MyApp                             0x000000010284d245 -[TAGContainer createInitialContainer] + 89
    11  MyApp                             0x000000010284afd3 -[TAGContainer initWithId:tagManager:resourceStorage:] + 399
    12  MyApp                             0x000000010284b098 -[TAGContainer initWithId:tagManager:] + 112
    13  MyApp                             0x000000010284ffe5 -[TAGManager containerById:] + 64
    14  MyApp                             0x000000010284f618 -[TAGManager openContainerById:callback:] + 258
    15  MyApp                             0x000000010284e9d3 -[TAGContainerOpener openWithRefreshType:] + 850
    16  MyApp                             0x000000010284e5c5 +[TAGContainerOpener openContainerWithId:tagManager:openType:timeout:notifier:] + 155
    17  MyApp                             0x0000000102812588 -[AnalyticsManager initWithTrackingId:containerName:] + 776
    18  MyApp                             0x00000001027b5afe -[TIXAppDelegate setupAnalytics] + 94

I can't seem to find any info scouring the web so far. The only thing I've seen so far is a mention in GA's Release notes that they've deprecated openContainerWithId possibly but their current guide says nothing about this or what to use instead.

Here's the container file contents:

{
    "exportFormatVersion": 1.3,
    "exportTime": "2015-06-23 16:11:59",
    "containerVersion": {
        "accountId": "197720",
        "containerId": "1300316",
        "containerVersionId": "0",
        "deleted": false,
        "container": {
            "accountId": "197720",
            "containerId": "1300316",
            "name": "App",
            "publicId": "GTM-MYCONTAINER",
            "timeZoneCountryId": "US",
            "timeZoneId": "America/Los_Angeles",
            "notes": "",
            "usageContext": [
                "IOS"
            ],
            "fingerprint": "1434997566330",
            "enabledBuiltInVariable": [
                "EVENT",
                "APP_ID",
                "APP_NAME",
                "APP_VERSION_CODE",
                "APP_VERSION_NAME"
            ]
        },
        "fingerprint": "0",
        "variable": [
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "1",
                "name": "UA Number",
                "type": "c",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "value",
                        "value": "UA-TrackingNumber"
                    }
                ],
                "fingerprint": "0"
            },
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "3",
                "name": "screen-from",
                "type": "v",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "screen-from"
                    }
                ],
                "fingerprint": "0"
            },
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "2",
                "name": "screen-name",
                "type": "v",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "screen-name"
                    }
                ],
                "fingerprint": "0"
            },
            {
                "accountId": "197720",
                "containerId": "1300316",
                "variableId": "4",
                "name": "view-name",
                "type": "v",
                "parameter": [
                    {
                        "type": "TEMPLATE",
                        "key": "name",
                        "value": "view-name"
                    }
                ],
                "fingerprint": "0"
            }
        ]
    }
}

Any help appreciated.

1

There are 1 answers

0
valheru On BEST ANSWER

It turns out, this issue can happen if no actual tags have been created on the server end of Google Tag manager.

Our analytics guy ended up doing the following: 1. Creating the needed tags on the server 2. Generating a new container file which we update in our code

Then the crash went away and everything worked.