Promotion
Stay organized with collections
Save and categorize content based on your preferences.
Class to construct promotion related fields for Google Analytics hits. The fields from
this class can be used to represent internal promotions that run within an app, such as
banners, banner ads etc.
Typical usage:
ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder();
builder.setPromotionAction(Promotion.ACTION_CLICK)
.addPromotion(new Promotion().setId("PROMO-ID1234").setName("Home screen banner."))
tracker.send(builder.build());
Public Constructor Summary
Inherited Method Summary
From class java.lang.Object
Constants
public static final String
ACTION_CLICK
Action to use when the user clicks/taps on a promotion.
Constant Value:
"click"
public static final String
ACTION_VIEW
Action to use when the user views a promotion.
Constant Value:
"view"
Public Methods
Sets the name of the creative associated with the promotion.
Parameters
value
The promotion creative's name. Example: "Cool pets creative"
Returns
- Returns the same object to enable chaining of methods.
Sets the id that is used to identify a promotion in GA reports.
Parameters
value
The promotion's id.
Returns
- Returns the same object to enable chaining of methods.
Sets the name that is used to identify the promotion in GA reports.
Parameters
value
The promotion's name. Example: "Home Banner"
Returns
- Returns the same object to enable chaining of methods.
Sets the position of the promotion.
Parameters
value
The promotion's position. Example: "top" or "bottom".
Returns
- Returns the same object to enable chaining of methods.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-10-31 UTC."],[[["\u003cp\u003eThe \u003ccode\u003ePromotion\u003c/code\u003e class is used to track internal app promotions like banners in Google Analytics.\u003c/p\u003e\n"],["\u003cp\u003eIt allows you to set details such as promotion ID, name, creative, and position.\u003c/p\u003e\n"],["\u003cp\u003eTwo predefined actions, \u003ccode\u003eACTION_CLICK\u003c/code\u003e and \u003ccode\u003eACTION_VIEW\u003c/code\u003e, are available to track user interactions.\u003c/p\u003e\n"],["\u003cp\u003eYou can use methods like \u003ccode\u003esetId\u003c/code\u003e, \u003ccode\u003esetName\u003c/code\u003e, \u003ccode\u003esetCreative\u003c/code\u003e, and \u003ccode\u003esetPosition\u003c/code\u003e to configure promotion details.\u003c/p\u003e\n"],["\u003cp\u003eThis data helps analyze promotion performance within your app.\u003c/p\u003e\n"]]],["The `Promotion` class constructs promotion fields for Google Analytics hits, representing in-app promotions like banners. Key actions are `ACTION_CLICK` (user clicks) and `ACTION_VIEW` (user views). You can use it with a `ScreenViewBuilder` to send promotion data. Core methods include `setId`, `setName`, `setCreative`, and `setPosition` to define promotion details. A constructor allows the creation of a `Promotion` object.\n"],null,["# Promotion\n\npublic class **Promotion** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nClass to construct promotion related fields for Google Analytics hits. The fields from\nthis class can be used to represent internal promotions that run within an app, such as\nbanners, banner ads etc.\n\nTypical usage: \n\n```\n ScreenViewBuilder builder = new HitBuilders.ScreenViewBuilder();\n\n builder.setPromotionAction(Promotion.ACTION_CLICK)\n .addPromotion(new Promotion().setId(\"PROMO-ID1234\").setName(\"Home screen banner.\"))\n tracker.send(builder.build());\n \n``` \n\n### Constant Summary\n\n|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|---------------------------------------------------------|\n| [String](//developer.android.com/reference/java/lang/String.html) | [ACTION_CLICK](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#ACTION_CLICK) | Action to use when the user clicks/taps on a promotion. |\n| [String](//developer.android.com/reference/java/lang/String.html) | [ACTION_VIEW](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#ACTION_VIEW) | Action to use when the user views a promotion. |\n\n### Public Constructor Summary\n\n|---|----------------------------------------------------------------------------------------------------|\n| | [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#Promotion())() |\n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion) | [setCreative](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#setCreative(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) value) Sets the name of the creative associated with the promotion. |\n| [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion) | [setId](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#setId(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) value) Sets the id that is used to identify a promotion in GA reports. |\n| [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion) | [setName](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#setName(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) value) Sets the name that is used to identify the promotion in GA reports. |\n| [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion) | [setPosition](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#setPosition(java.lang.String))([String](//developer.android.com/reference/java/lang/String.html) value) Sets the position of the promotion. |\n| [String](//developer.android.com/reference/java/lang/String.html) | [toString](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion#toString())() |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nConstants\n---------\n\n#### public static final [String](//developer.android.com/reference/java/lang/String.html)\n**ACTION_CLICK**\n\nAction to use when the user clicks/taps on a promotion. \nConstant Value: \"click\" \n\n#### public static final [String](//developer.android.com/reference/java/lang/String.html)\n**ACTION_VIEW**\n\nAction to use when the user views a promotion. \nConstant Value: \"view\"\n\nPublic Constructors\n-------------------\n\n#### public **Promotion** ()\n\nPublic Methods\n--------------\n\n#### public [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion)\n**setCreative** ([String](//developer.android.com/reference/java/lang/String.html) value)\n\nSets the name of the creative associated with the promotion. \n\n##### Parameters\n\n| value | The promotion creative's name. Example: \"Cool pets creative\" |\n|-------|--------------------------------------------------------------|\n\n##### Returns\n\n- Returns the same object to enable chaining of methods. \n\n#### public [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion)\n**setId** ([String](//developer.android.com/reference/java/lang/String.html) value)\n\nSets the id that is used to identify a promotion in GA reports. \n\n##### Parameters\n\n| value | The promotion's id. |\n|-------|---------------------|\n\n##### Returns\n\n- Returns the same object to enable chaining of methods. \n\n#### public [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion)\n**setName** ([String](//developer.android.com/reference/java/lang/String.html) value)\n\nSets the name that is used to identify the promotion in GA reports. \n\n##### Parameters\n\n| value | The promotion's name. Example: \"Home Banner\" |\n|-------|----------------------------------------------|\n\n##### Returns\n\n- Returns the same object to enable chaining of methods. \n\n#### public [Promotion](/android/reference/com/google/android/gms/analytics/ecommerce/Promotion)\n**setPosition** ([String](//developer.android.com/reference/java/lang/String.html) value)\n\nSets the position of the promotion. \n\n##### Parameters\n\n| value | The promotion's position. Example: \"top\" or \"bottom\". |\n|-------|-------------------------------------------------------|\n\n##### Returns\n\n- Returns the same object to enable chaining of methods. \n\n#### public [String](//developer.android.com/reference/java/lang/String.html) **toString** ()"]]