Google Analytics iOS. How to use -send:params: ? - ios

API version is GoogleAnalyticsiOS_2.0beta4.
The problem I'm dealing with is next:
f.e. I have several screens with one of them called PagesScreen.
PagesScreen have several pages.
In addition to screen tracking, I wish to track pages visited by user.
If I use custom dimension, f.e. pageName in conjunction with
[tracker sendView:#"Page View"], obviously, each time page changes, page visits being added to screen visits with #"Page View" screen name. I don't want to page views statistics being mixed with screen views. Therefore I don't have to call sendView: API. sendEvent: API is also not suitable for my case.
The remaining method is:
- (BOOL)send:(NSString *)trackType params:(NSDictionary *)parameters;
But neither it's description tells me about usage, nor mentions I've found in iOS integration guide.
What is trackType and what is parameters structure? Does anybody knows how to use it?

I think you can find the allowed trackTypes and required parameters on the following page:
https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
For instance, to send an event via send:parameters, the trackType should be #"event" and should have the following keys/values:
&ec=video // Event Category. Required.
&ea=play // Event Action. Required.
&el=holiday // Event label.
&ev=300 // Event value.
Hope this helps!

Related

How do i set an eVar value in Adobe Analytics?

I couldn't find an answer to my question anywhere so i decided to post it here.
So, we have eVar33 set up within adobe analytics, when someone submits a form on our website how do i set eVar33 equal to the email address field?
$("form").submit(function(){
$("input#email").val(eVar33);
});
I'm assuming you have an appmeasurement library (aka s_code) on your page. In that case, Crayon Violet is right, something like this is what you want:
$("form").submit(function(){
s.eVar33 = $("input#email").val();
});
That will set the variable. To send it to Adobe, you need to fire either s.t() (for a page view) or, as is more likely the case for you, s.tl() (for things you want to track not associated with a page view- https://marketing.adobe.com/resources/help/en_US/sc/implement/function_tl.html and https://marketing.adobe.com/resources/help/en_US/sc/implement/link_variables.html.)
I suspect in the end, you'd do something like this:
$("form").submit(function(){
s.eVar33 = $("input#email").val();
s.linkTrackVars="eVar33"
s.tl(this,"o","form submitted")
});

How to add a Adobe Analytics Variable to multiple Link Track rule in Dynamic Tag Manager

I have more than 100 DTM rules which has been set up to capture Analytics link track. Now, I have new requirement to add one global variable (let's say eVarX) to all of the link tracking. Could someone please help me how it can be done without adding it manually to each link track rule.
DTM does not currently have a way to globally add variables to all Adobe Analytics (AA) hits. The closest thing you can do is make use of AA's doPlugins callback function, which you can define in the custom code box of the AA tool config page.
If you do not already have doPlugins (commonly namespaced s_doPlugins) function defined there, then in the custom code box of the Adobe Analytics tool, add the following:
s.usePlugins=true;
s.doPlugins=function(s) {
// add variable here
// make sure to also "register" it in `linkTrackVars`
// for s.tl calls
}
Note: This is global, as in, it will trigger for all s.t and s.tl calls, not just those specific 100 DTM rules. There's no good way to effectively say "only do it for [some list of rules]" except to just individually add it to your rules.

ADBMobile trackState vs ADBMobile trackAction

I have a question about the SDK 4.x of Adobe Analytics for iOs.
How can we track an event during a trackState call?
For example in a login confirmation page I need to track:
Pagename: "Login Page"
eVarX: "logged"
eventX: that counts the login event
Is this the right code that I need to send our developing team:
NSMutableDictionary *contextData = [NSMutableDictionary dictionary];
[contextData setObject:#"logged" forKey:#"myapp.login.LoginStatus"];
[ADBMobile trackState:#"Login Page" data:contextData];
[ADBMobile trackAction:#"myapp.Login" data:contextData];
Thank a lot
What you have should work fine.
Unlike Adobe's legacy javascript implementation (where you explicitly set variables/events by name), all of the iOS variable mapping is done through the "Manage Variables and Metrics" area within Adobe Mobile services (see https://marketing.adobe.com/resources/help/en_US/mobile/ios/actions.html for details). On that configuration screen, you would assign the myapp.Login action to the appropriate event and myapp.login.LoginStatus to the appropriate eVar.
Alternatively, you can perform the mapping through Processing Rules if you have access to that feature. Beyond the above functionality, this can give additional flexibility if you want to set a rule-based event based on contextData values.
In terms of simplicity and code readability, I'd recommend the first option.

Set the Visitor ID in Adobe Analytics through DTM

I'm trying to set the Visitor ID in Adobe Analytics through DTM.
Above the s_code I have:
var visitor = new Visitor("xxxx")
visitor.trackingServer = "xxx.xx.xx.omtrdc.net"
I've created a data element where the legacy code used to call the
Visitor.getInstance("xxxx");
and set the Visitor ID to %Visitor ID%
That's not working however, and my visitor ID is always just set to %Visitor ID% and obviously not reading any values. I'd really appreciate any input that someone can give me.
Thanks,
Mike
The Visitor ID pops s.visitorID and is in general related to visitor id, but is not the same as s.visitor which is what gets popped for the VisitorAPI integration. DTM does not currently have a built-in field for the s.visitor variable, so you will have to set it yourself within the config, either in the Library Management code editor (assuming you are opting to c/p the core lib and not the "Managed by Adobe" option) or else in the Custom Page Code section.
Since you are popping it in a data layer first, you can reference the data layer like this:
s.visitor = _satellite.getVar('Visitor ID');
NOTE: A separate potential issue you may have is with whether or not the Visitor object is available for your data element. Since data elements are the first thing to be evaluated by DTM, you will need to ensure that the VisitorAPI.js library is output before your top page DTM script include.
If this is a problem for you, or if you are wanting to host VisitorAPI.js within DTM, then you may need to adjust where you are popping that stuff. For example, place the VisitorAPI core code above the custom code as the first stuff within the data element, before:
var visitor = new Visitor("xxxx") visitor.trackingServer = "xxx.xx.xx.omtrdc.net
Or, don't use the data element at all. Instead, put the VisitorAPI code within the Adobe Analytics custom code or core lib section and pop all that stuff (aboove the s.visitor assignment). Or a number of other methods; point is, VisitorAPI stuff must be loaded before the data element can make use of it, same as it must be loaded before Adobe Analytics can make use of it.
So DTM is changing pretty fast and furious right now. They have a "Marketing Cloud Service ID" that works well. Before I used that, however, I did find a way to fix the code. Crayon Violent was right, as usual, that the problem was that the script wasn't available yet. I fixed this by putting the following code in between the VisitorAPI.js and the AppMeasurement stuff in the DTM managed library.
var aA = new AppMeasurement();
aA.visitorNamespace="companyname";
aA.visitor = Visitor.getInstance("companyname");
In addition, there were also some issues using my localhost for testing while trying to see if I had this correct or not. If you are having issues and think you have it correct, it may be worthwhile to elevate it to a different environment.

twitter: share link with parameters

I have a share button on my site.
But I need to share link with parameters, and each time parameters will be different (I need to track user who is sharing, etc.)
For example need to share link like http://mySite.com/page?userId=111&someParam=222
I can share this well, but how can I force count to work correct?
if I set
data-url="http://mySite.com/page?userId=111&someParam=222"
data-counturl="http://mySite.com/page/"
I am getting count 0 always. How to get this work?
From http://dev.twitter.com/pages/tweet_button,
"The count box shows how many times the URL has been Tweeted."
Your problem is you simply have the url and counturl mixed up. Change url to the short one, for display purposes - that's the one people will see. Use the counturl for the one with all the parameters, to ensure they go to the right place with the parameters intact.
I suspect the reason your count kept showing zero tweets is because you have a different (unique) url as your primary url each time it is tweeted, so each tweet is the first time that url (including its parameters) was shared.
Twitter now lets you send the url through data attributes. This works perfectly for me and should work for you out of the box!
The button (check out data-url):
Tweet
The twitter javascript snippet (from https://dev.twitter.com/docs/tweet-button)
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>

Resources