Getting started with MRGSMyTracker🔗
MyTracker - SDK for collecting statistics, read more on the official website. MRGS allows you to automatically start the sdk and pass most of the necessary events to it and much more.
MyTracker is only supported for mobile platforms.
To integrate, you need to follow a few simple steps:
Step 1. Import MRGSMyTracker module🔗
Adding to Unity project (general instruction)
Step 1. Add Sources
To add MRGS to a project via the Unity Package Manager (available from Unity 2018+) simply add a scopedRegistries section to the Packages/manifest.json file by adding the following entry:
{
"dependencies": {
...
},
"scopedRegistries": [
{
"name": "MRGS",
"url": "https://mrgs-nexus.my.games/repository/mrgs-uninty-plugins/",
"scopes": [
"games.my.mrgs"
]
}
]
}
Alternatively, you can click Edit -> Project Settings -> Package Manager -> '+' in scoped registry section, and fill in the fields according to the data above.
Step 2. Add dependency
- Click
Window -> Package Manager -> select 'Packages: MyRegistries' from dropdown list, select packageMRGSMyTrackerfrom the list, then click "Install" - Import the module:
using MRGS;
- Download the latest version of the library. Unzip the archive.
- (For unitypackage integration) In Unity, click
Assets -> Import Package -> Custom Package, and select thegames.my.mrgs.mytracker.unitypackagepackage from the downloaded archive. - (For tgz integration) In Unity, click
Window -> Package Manager -> '+' -> Add package from tarball, and select thegames.my.mrgs.mytracker-<version> package. tgzfrom the downloaded archive. - Import the module:
using MRGS;
Adding to iOS project (general instruction)
Step 1: Add dependencies
Via Package collection
- In Xcode select File > Add Packages
- Select "+" > "Add Swift Package Collection"
- Insert URL:
https://mrgs-nexus.my.games/repository/ios-sdks/MRGSPackageCollection.json - Select module MRGSMyTracker from "MRGS Package Collection".
- Or you can select "MRGS" package from "MRGS Package Collection" (contains all mrgs modules as products) and then select "MRGS/MyTracker" product only.
Individual packages
- In Xcode select File > Add Packages
- In the search bar at the top right, paste the URL:
https://mrgs-gitea.my.games/mrgs/mrgsmytracker-ios-sdk.git - Add a module to your project
- Or you can paste the url
https://mrgs-gitea.my.games/mrgs/ios-sdks.gitto include the "MRGS" package which contains all mrgs modules as products and then select only the product" MRGS/MyTracker".
Step 2: Add support for ObjectiveC categories
- Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGSMyTracker;or#import <MRGSMyTracker/MRGSMyTracker.h>
Step 1. Add Sources
In your podfile, add sources to the top of the file:
source 'https://github.com/CocoaPods/Specs.git' # For main repo
source 'https://mrgs-gitea.my.games/mrgs/cocoapods-specs.git' # For MRGS repo
Step 2: Add dependencies
Add the latest version of MRGSMyTracker to target:
To add via subspecs:
To add via individual modules:
To add all mrgs modules:
Step 3: Install dependencies
- Run
pod install(orpod install --repo-updateif necessary) - Import the module in code:
@import MRGServiceKit;or@import MRGSMyTracker;or#import <MRGSMyTracker/MRGSMyTracker.h>
Step 1: Add dependencies
Add the dependency to your Cartfile:
Step 2: Install dependencies
- Run
carthage update --use-xcframeworks - Add downloaded frameworks to your project (make sure "do not embed" option is enabled)
- Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGServiceKit;or@import MRGSMyTracker;or#import <MRGSMyTracker/MRGSMyTracker.h>
- Download the latest version of the library. Unzip the archive.
-
Add
MRGSMyTracker.xcframeworkfrom the downloaded archive to your project (Drag the libraries to the "Linked frameworks and Libraries" section) (Also contains MRGSMyTracker.framework for compatibility - fat framework) -
Set the
-ObjCflag in the "Other linker Flags" field in the project settings. - Import the module in code:
@import MRGSMyTracker;or#import <MRGSMyTracker/MRGSMyTracker.h> - Also, you can add the
MRGServiceKit.handmodule.modulemapfiles from the archive to your project, or specify the path to them in the project settings in theBuild Settings -> Header search pathssection. Now, instead of importing each of our frameworks separately, you can only import one header file:@import MRGServiceKit;
Adding to Android project
Copy the MRGSMyTracker.aar file to the libs directory of your project. Add the necessary dependencies to the build file.
Since version 6.0.0-a MyTracker is a separate module
Huawei/AppTouch Store
Add dependency as per documentation
Step 2. Preliminary setup and initialization🔗
When starting MRGS SDK you need to pass parameters (MY_TRACKER_SDK_KEY) and settings for MyTracker:
@import MRGService;
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// MRGService settings
MRGServiceParams *mrgsParams = [[MRGServiceParams alloc] initWithAppId: <MRGS_APP_ID> secret: <CLIENT_SECRET>];
// MyTracker
MRGSMyTrackerParams *myTrackerParams = [[MRGSMyTrackerParams alloc] initWithAppId: <MY_TRACKER_SDK_KEY>];
myTrackerParams.forwardMetrics = YES; // All MRGS metrics sent through the MRGSMetrics class will automatically be sent to MyTracker
//Start MRGS
[MRGService startWithServiceParams:mrgsParams externalSDKParams:@[myTrackerParams] delegate:nil];
}
import java.util.ArrayList;
import java.util.List;
import games.my.mrgs.MRGSModuleParams;
import games.my.mrgs.MRGSPlatform;
import games.my.mrgs.MRGService;
import games.my.mrgs.MRGServiceParams;
import games.my.mrgs.my.tracker.MRGSMyTrackerParams;
public class YourApplicationClass extends Application {
@Override
public void onCreate() {
super.onCreate();
final MRGServiceParams serviceParams = MRGServiceParams.init(<MRGS_APP_ID>, <CLIENT_SECRET>, MRGSPlatform.ANDROID);
serviceParams.setDebuggable(false);
// Settings for MRGSModules
final List<MRGSModuleParams> moduleParams = new ArrayList<>();
// Setting MyTracker
final MRGSMyTrackerParams myTrackerParams = MRGSMyTrackerParams.init("MY_TRACKER_SDK_KEY");
myTrackerParams.setDebuggable(false);
moduleParams.add(myTrackerParams);
MRGService.service(context, serviceParams, moduleParams);
}
}
MY_TRACKER_SDK_KEY
MY_TRACKER_SDK_KEY - SDK key of the MyTracker library. It can be obtained from the MyTracker website in the settings section of your application ![]()
Important! Don't forget that this setting is different for Android and iOS builds. Use the correct initialization keys
Step 3. Login tracking🔗
For the correct calculation of game statistics (the number of registrations and authorizations, as well as LifeTime payments) in the MyTracker/1link system, it is necessary to report these events using the following methods:
Attention!
trackLoginEvent must be called in any case - whether the user was registered or authorized. The trackRegistrationEvent method should only be called when registering (creating) a user account. Both of these methods must be called after calling the MRGSUsers#setUserId method otherwise the events will be sent without a user id and the statistics will be inaccurate.
Automatic events sending🔗
MRGS will automatically call the following MyTracker methods to send the necessary events:
- When initializing MyTracker, the customUserId parameter will be set. USER_ID will be transferred there if there is one saved from the previous session
- After receiving deviceId, the setMrgsId method will be called with the received deviceId
- When calling the
MRGSUsers#setUserIdmethod, the customUserId parameter of MyTracker will be set - When sending a metric, the trackEvent method will be called if metrics forwarding has not been disabled
- For Unity, when the game starts, the trackLaunchManually method will be called
- When making a payment on Android, the trackPurchaseEvent method will be called. On iOS, MyTracker subscribes to a transaction queue on its own to track payments made.
Sending events🔗
Using this API, you can send events to MyTracker directly. For instance:
Managing sending parameters🔗
You can set the interval in seconds during which events will accumulate on the device before sending them to the server. The default interval is 900 seconds. The value can be set in the range of 1-86400 seconds (24 hours).
Also, you can set the interval in seconds during which events will accumulate on the device before sending them to the server. The default interval is 900 seconds. The value can be set in the range of 1-86400 seconds (24 hours).
Also, you can set the interval in seconds during which a new launch is not tracked and a session is not interrupted while app is in background. Possible values range: 30-7200 seconds. 30 sec by default.
To send the accumulated events immediately, use the flush method (We do not recommend calling it too often).
Getting data from MyTracker🔗
To get a unique InstanceID for S2S events sending, use the method:
Working with attribution (Deeplink and Deffered deeplink)🔗
To support deeplinks and deferred deeplinks (Deeplink or Deffered deeplink), you need to install a delegate in your application (not important before or after starting MRGS) to get information about them. The delegate will be called upon the first launch of the application if a delayed diplink was found for the current installation, as well as every time the application is launched via the diplink. An attribute object MRGSMyTrackerAttribution containing the deeplink property will be passed as a parameter when called:
// Setting the delegate:
// Where self is an object that implements the MRGSMyTrackerAttributionDelegate protocol
[MRGSMyTracker setAttributionDelegate: self];
// Implementation of the delegate:
- (void)didReceiveAttribution:(nonnull MRGSMyTrackerAttribution *)attribution {
NSLog(@"MRGSMyTracker didReceiveAttribution delegate called with data - %@", attribution.deeplink);
}
DeepLinks allow you to pass additional parameters to it when you start the application. These options can be used to go to a specific application screen. Deferred deeplinks allow you to transfer additional parameters to the application at the first start after installation. These parameters can be used in the same way as in the case of conventional DeepLink.
To set up delayed deeplinks from MyTracker, refer to the MyTracker documentation.
Manage event tracking from MRGSMetrics🔗
By default, MRGSMetrics duplicates events in MyTracker. If for some reason you need to disable sending, just add the setting in setup:
Setting customerUserID🔗
If you want to set your own userId, you need to call the specified method before initializing MRGS, passing null there (then we will not put any data in this field at the start of the sdk), and after you have the userId, set it through the specified method. Also, you can immediately set your userId before the start of MRGS.
Tracking location🔗
MRGS disables user location tracking in MyTracker by default, if for some reason you need to change this behavior, then just add the setting in setup:
Created: 2020-01-20