Implementing and Verifying Google Tag Manager Custom Function in iOS (Swift)


I have an iOS app in which I’ve integrated the Firebase SDK and I can see some basic events firing on the Firebase debug console as expected.

Next, I want to integrate Google Tag Manager(GTM) and I followed this step by step guide to integrate Google Tag Manager into an iOS project which suggests to use Firebase Analytics to send events to Google Tag Manager.

The challenge I’m currently facing is two fold:

  1. I’ve followed all the steps in the documentation but how can I verify that GTM console has been configured correctly and I’ve integrated everything properly ? The preview for mobile apps has such limited documentation and I don’t see any logs in the Xcode console related to GTM.
  2. I’m trying to implement something called custom function calls for which the documentation is here

This is my setup on the GTM console GTM Custom Function Calls iOS Swift which I got from this article

But again, I don’t see any logs or even the function getting invoked, this is my code:

@objc
class AnalyticsVariableProvider: NSObject, TAGCustomFunction {
    @objc
    func execute(withParameters parameters: [AnyHashable: Any]!) -> NSObject! {
        guard let parameters else {
            print("no parameters")
            return nil
        }
        
        print("reached")
        print(parameters)
        
        return nil
    }
    
    required override init() {
        super.init()
    }
}

I’ve tried looking at some of these other SO threads:

  1. GTM – iOS Custom Tag is not triggered
  2. How to get Callback for Google Tag Manager in ios?
  3. Using GTM v5 TAGCustomFunction in Swift

But so far none of these helps me.

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img