0
votes

I'm currently looking into setting up Google Tag Manager in iOS Swift. The Google developer docs currently don't have anything on Swift, only on Objective-C. Does anyone have any experience with setting up GTM in Swift?

The current iOS docs can be found here: https://developers.google.com/tag-manager/ios/v3/

Thanks a lot to anyone who can point me in the right direction!

2
FWIW, the ios doc are outdated and the screenshots actually point to a prior version of GTM. Additionally, the code example in ObjC uses a deprecated call to load the container. - Steve

2 Answers

0
votes

first off I might be a bit too late in helping you here, secondly: I just started implementing this for my app today, and since I write it in Swift, I obviously have the same issue as you. However, I managed to install the SDK now and I can access the TAGManager and the code to open the container.

I installed the SDK using CocoaPods, so unless you also do that I can't really help you with adding the SDK to your project. I would really recommend using CocoaPods though. But since the SDK is written i ObjC you need to bridge the header files in order to use it in swift.

Here is the CocoaPod for Google Tag Manager: https://cocoapods.org/pods/GoogleTagManager

And here is the link I used to get the header files to bridge:http://thiagoborg.es/blog/2014/10/29/manage-objective-c-dependencies-with-cocoapods-on-swift-project/

In the link you provided I'm currently at Getting Started - 3. Opening a Container. Unfortunately I can't get it to open, it stated that it can't find my binary.

Hope this helps somewhat, though :)!

0
votes

Anyone coming across this may have been frustrated by the rogue tutorials floating around for version 3 of Google Tag Manager. Your Bridging header will not compile !

What you want is the version 5 of Tag Manager

https://developers.google.com/tag-manager/ios/v5/#fire-tags