Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom properties for screen tracking events #137

Open
andrewsardone opened this issue Feb 26, 2015 · 3 comments
Open

Allow custom properties for screen tracking events #137

andrewsardone opened this issue Feb 26, 2015 · 3 comments

Comments

@andrewsardone
Copy link

First of all, nice work on ARAnalytics!

I have a project that uses the DSL configuration for tracking screen views. It’s the standard setup for naive screen tracking via an ARAnalyticsTrackedScreens config. It works well, but I’m up against a problem: out-of-the-box screen tracking does not allow you to tack on additional event properties.

When adding a screen monitor hook, additional configuration values like ARAnalyticsEventProperties are ignored, and the didShowNewPageView: implementation just hardcodes an event and properties.

I’m okay with hardcoding the event name – I like the opinionated screen tracking event – but it’d be nice if I could tack on additinoal properties:

[ARAnalytics
    setupWithAnalytics:@{ /**/ }
    configuration:@{
        ARAnalyticsTrackedScreens: @[
            @{
                ARAnalyticsClass: UIViewController.class,
                ARAnalyticsDetails: @[
                    @{
                        ARAnalyticsPageNameKeyPath: @"mySpecialAnalyticsKeyPath",
                        ARAnalyticsEventProperties: ^NSDictionary*(UIViewController *controller, id _) {
                            return @{
                                @"a special property": @"foo",
                            });
                        }
                    }
                ],
            }
        ]
    }];

The sent Screen view propeties would then be a union of the default @{ @"screen": pageTitle} dictionary and the value of ARAnalyticsEventProperties.

I’m filing this as an issue to see if it gets a basic 👍 or 👎. If the former, I’ll take a stab at a PR.

Thanks!

@orta
Copy link
Owner

orta commented Feb 26, 2015

Looks good to me, especially if you're OK with the current naive implementation. We're still using the RAC branch. So please ensure backwards compatibility.

@orta
Copy link
Owner

orta commented Mar 23, 2015

3.0.0+ uses our RAC branch as default, I believe this allows you do this.

@rais38
Copy link
Contributor

rais38 commented Nov 6, 2015

Custom properties is working currently but I need custom event name for tracked screens in Mixpanel. I can see that ARAnalyticalProvider is very coupled to Google Analytics.

I'm seeing the best way is override didShowNewPageView: implementation in MixpanelProvider:

- (void)didShowNewPageView:(NSString *)pageTitle withProperties:(NSDictionary *)properties {
    NSDictionary *props;
    if (properties.count > 0) {
        NSMutableDictionary *merge = [properties mutableCopy];
        merge[ARAnalyticalProviderNewPageViewEventScreenPropertyKey] = pageTitle;
        props = [merge copy];
    } else {
        props = @{ ARAnalyticalProviderNewPageViewEventScreenPropertyKey: pageTitle };
    }

    NSString *eventName;
    if (properties[ARMixpanelTrackedScreenEventName]) {
        eventName = properties[ARMixpanelTrackedScreenEventName];
    } else {
        eventName = ARAnalyticalProviderNewPageViewEventName;
    }
    [self event:eventName withProperties:props];
}

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants