klaviyo / klaviyo-swift-sdk

SDK that allows users to incorporate Klaviyo's event and person tracking functionality within iOS applications. Written in Swift.
MIT License
10 stars 10 forks source link

Not able to see OPEN RATE on Klaviyo's dashboard #90

Closed iballan closed 11 months ago

iballan commented 1 year ago

Description

Reported the same issue on Android sdk too https://github.com/klaviyo/klaviyo-android-sdk/issues/78

But on Android we had to customize the behavior and log OPENED_PUSH manually. On iOS it is not working even though we are using the SDK's version of handling notification.

        let isKlaviyoNotification = KlaviyoSDK().handle(notificationResponse: response, withCompletionHandler: completionHandler, deepLinkHandler: deeplinkHandler)
        if !isKlaviyoNotification {
             // our code goes here
        }

KlaviyoSDK().handle should be handling the logic of logging OPENED_PUSH event, yet i tried to create the event and send it to make sure it is sent to Klaviyo. Yet i don't see open rate on the dashboard

Checklist

Expected behavior

When I send push notification from klaviyo's dashboard and click on it, I expect to see 1 opened notification on the dashboard.

Actual behavior

Open rate is 0% all the time no matter how I log the OPENED_PUSH event

Steps to reproduce

Send push notification to iOS, clicking it won't show open rate on the dashboard

The Klaviyo Swift SDK version information

2.0.1

Destination operating system

iOS 16

Xcode version information

14.3.1

Swift Compiler version information

Swift 5
ndurell commented 1 year ago

Thanks for filing! Will take a look today!

ndurell commented 1 year ago

Hey! Thanks for your patience with this issue. I'm having a little trouble reproducing this bug. To attempt reproduce I sent myself a campaign notification to a test app and click opened on it while the app was running. I was able to see the open event was logged and I now see the event in the user's timeline. Can you tell me more about your setup? Where did you put the open tracking code above? Are you opening a push notification from Klaviyo or from another service? Our SDK currently does not log opens from other services.

iballan commented 1 year ago

Hey @ndurell, Actually on iOS we use the standard Klaviyo sdk flow to do that, where on Android we don't. This is the didReceive method:

    func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
        let isHandledByKlaviyo = KlaviyoManager.shared.handleKlaviyoNotifiction(response: response, withCompletionHandler: completionHandler) { [weak self] url in
            self?.handleDeepLinking(url: url)
        }
        if !isHandledByKlaviyo {
             // Here we handle our Firebase Messaging notification
             let url = // get deeplink from the response
            handleDeepLinking(url: url)
            completionHandler()
        }
        // get some payloads info for our analytics service
        analyticsManager.trackNotificationClicked(..some payloads, isKlaviyo: isHandledByKlaviyo)
    }

The KlaviyoManager class is just a wrapper on the KlaviyoSDK(), this is handleKlaviyoNotifiction mentioned in the code above:

    func handleKlaviyoNotifiction(response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void, deeplinkHandler: @escaping (URL) -> Void) -> Bool {
        let handled = KlaviyoSDK().handle(notificationResponse: response, withCompletionHandler: completionHandler, deepLinkHandler: deeplinkHandler)
        return handled
    }
ndurell commented 1 year ago

Ahh ok this is great and does look correct. However I'll give this a try in our test app and get back to ya.

ndurell commented 1 year ago

Quick update: so far I'm not able to repro this. We would like to get you unblocked so I've reached out offline to schedule time to sync up directly on this. One other thing you might want to check is that the open code is being hit when you open the push. Potentially you could add some logging to ensure the handle call is being made to our sdk.

ndurell commented 1 year ago

Actually a couple other things you can check (if you haven't already):

  1. Are you setting any other delegate methods related to push?
  2. Are you setting the user notification delegate?

I assume this was completed but just wanted to check that as well.

iballan commented 1 year ago

@ndurell hmm I will check that and get back to you

iballan commented 1 year ago

Yeah I made sure we have the UNUserNotificationCenter.current().delegate set, and have func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) and contains Klaviyo.handle in it.

The thing is we are getting Klaviyo's notification and clicking it taking us to the deeplink. So most probably the code of the delegate is hit, but since not able to run in debug mode i am not sure whether Klaviyo.handle returns true or false

iballan commented 1 year ago

I just debugged the code i sent above for sandbox Firebase notification, it works just fine. Klaviyo.handle returns false for Firebase notification and deeplinks handled correctly

ndurell commented 12 months ago

Hey @iballan can you update this issue once you hear back from QA?

ndurell commented 11 months ago

Hey @iballan did QA have any luck with the open rate?

iballan commented 11 months ago

Hey @ndurell I was on vocation last week, I've seen that our QA is working on it this week. I will let you know about the results soon.

iballan commented 11 months ago

Hi @ndurell Finally with the good news :) Everything is working just fine! Thank you all for your help! Much appreciated.

ajaysubra commented 11 months ago

Glad everything worked out @iballan. Please reach out if you have any issues in the future. Closing this issue now.