Custom Variables with Google Analytics for Low Level Mobile Devices (no javascript)

I am working on the Mxit platform and want to create and capture some custom variables for storage in Google Analytics.

With Mxit ports, this is not the usual connection between a browser and a web server. This application is for phone, mxit server, web server. Mxit sits in the middle, which means we cannot directly capture user information.

However, Mxit sets up custom headers with additional user information that can be written to Google Analytics through user variables.

We cannot use javascript, so Ive installed Google Analytics for mobile php script, which creates and adds data to the gif image.

I set custom variables on a regular website using javascript and using GA debugging I copied the utme parameter and added it to GA for mobile PHP code to manually add it to the gif query string.

Here is a quick, simplified, simplified example:

Custom values ​​that I would like to set.

$id = $headers['mxitID']; $country = $headers['country']; $gender = $headers['gender']; $age = $headers['age']; 

and here i add the gif query string

 &utme=8(MxitID*Country*Gender*Age)9($id*$country*$gender*$age)11(1*1*1*1) 

As I understand it, 8 () represents the names of custom variables, 9 () represents the values ​​of the user variable, and 11 () represents the scope.

This happened after 2 days, and Google Analytics still has no information about user variables.

I check visitors> User Variables

Any help would be appreciated.

+6
source share
2 answers

Google has a server solution only for this problem. The code can be found here: https://developers.google.com/analytics/devguides/collection/other/mobileWebsites

Here is the implementation of this library

 <?php class GoogleAnalytics { const ACCOUNT = "ACCOUNT ID GOES HERE"; const PIXEL = "/ga.php"; public static function getImageUrl() { $url .= self::PIXEL . '?'; $url .= 'utmac=' . self::ACCOUNT; $url .= '&utmn=' . rand(0, 0x7fffffff); $referer = !empty($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '-'; $url .= '&utmr=' . urlencode($referer); if (!empty($_SERVER["REQUEST_URI"])) { $url .= "&utmp=" . urlencode($_SERVER["REQUEST_URI"]); } $url .= '&guid=ON'; return str_replace('&', '&amp;', $url); } } ?> 

And then, in your opinion, you:

 <img src="<?php echo GoogleAnalytics::getImageUrl() ?>" /> 
+1
source

I wrote code for this.

You can change it however you want.: {D

https://github.com/WillemLabu/ga-collection

0
source

Source: https://habr.com/ru/post/893342/


All Articles