Getting Container Data

The Google Tag Manager has few standard macro type. You can found it section bellow.

  • Advertising tracking enabled - Android: Returns true if ad tracking is enabled, or false if the user has opted out of interest-based ads. More info in the Android Developer Center. SDK versions prior to v4 will always return falsely.
    iOS: For iOS versions 6 and greater, the value is set to the advertisingTrackingEnabled property. Otherwise, the value is set to true.

  • App id - Android: The value is set to the package name.
    iOS: The value is set to the bundle ID.

  • App name - The value is set to the name of the currently running application.

  • App version - The value is set to the version of the currently running application.

  • Device id - Android: The value is set to the device ID.
    iOS: The value is set to "" (the empty string).

  • Device name - The value is set to the device name of the currently running application (e.g., "Samsung Android", "Android SDK built for x86").

  • Id for advertising - Android: The value is set to the Advertising ID. More info in the Android Developer Center. SDK versions prior to v4 will always return "" (the empty string).
    iOS: For iOS versions 6 and greater, the value is set to the identifier for advertising (IDFA). Otherwise, the value is set to "" (the empty string).

  • Language - The value is set to the two-letter language code representing the user-set device language.

  • Os version - The value is set to the version of the operating system in which the application is installed.

  • Platform - The value is set to the platform of the currently running application (e.g., "Android").

  • Screen resolution - The value is set to the screen resolution of the device of the currently running application. The format is "<width>x<height>", e.g., "1024x768".

  • Sdk version - The value is set to the SDK version of the operating system in which the application is installed.

  • True - The value is set to the string you provide.

 

To get the value of a standard macro, for example, a screen resolution need to call

string resolution = TagManagerObject.Instance.GetString (âââ¬Ãâscreen resolutionâââ¬ÃÂ).

 

Use Example

  1. Create the new container.

  2. Add to container Value Collection macro with value: 

    { "max-fuel": 200,  "init-fuel": 100,  "fuel-burn-rate": 20 }.

     

  3. Publish container.

  4. Create empty Game Object and attach following  C# script to it:

public class TestContainer : MonoBehaviour
{
	private static string MAX_FUEL_KEY = "max-fuel";
	private static string INIT_FUEL_KEY = "init-fuel";
	private static string FUEL_BURN_KEY = "fuel-burn-rate";

	private double maxFuel;
	private double startingFuel;
	private double burnRate;

	void OnGUI () {
		GUILayout.Label ("MAX FUEL: " + maxFuel.ToString ());
		GUILayout.Label ("INIT FUEL: " + startingFuel.ToString ());
		GUILayout.Label ("FUEL BURN RATE: " + burnRate.ToString ());
	}


	void FixedUpdate () {
		maxFuel = TagManagerObject.Instance.GetDouble (MAX_FUEL_KEY);
		startingFuel = TagManagerObject.Instance.GetDouble (INIT_FUEL_KEY);
		burnRate = TagManagerObject.Instance.GetDouble (FUEL_BURN_KEY);
	}
}

 

After building in the device you will get the similar result:

1.png