Configure Firebase Analaytics + Google Tag Manager (GTM) per build variant

前端 未结 2 2008
灰色年华
灰色年华 2021-02-20 01:59

Before Firebase Analytics became available we use a multi flavour, multi build type Android Gradle project setup, and supply a different GTM container ID for each build variant,

2条回答
  •  爱一瞬间的悲伤
    2021-02-20 02:38

    This is how we set up our Gradle multi-flavor project to use different GTM container for each build variant:

    /
    |_app/
      |_src/
        |_flavor1/
        | |_google-services.json # Google services config for debug
        | |_release/
        |   |_google-services.json # Google services config for flavor1
        |_flavor1Release/
        | |_assets/
        |   |_containers/
        |     |_GTM-ABCXY1.json # GTM container for flavor1
        |
        |_flavor2/
        | |_google-services.json # Google services config for debug
        | |_release/
        |   |_google-services.json # Google services config for flavor2
        |_flavor2Release/
        | |_assets/
        |   |_containers/
        |     |_GTM-ABCXY2.json # GTM container for flavor2
        |
        |_debug/
        | |_assets/
        |   |_containers/
        |     |_GTM-ABCXY3.json # GTM container for debug
        |
        |_main/
          |_res/
          |_java/
    

    Assuming you have 2 flavors flavor1 and flavor2, and want to have 3 GTM containers, 1 shared for debug build of both flavors, and 1 each for release build of each flavor.

    GTM will connect to the FA dashboard of the project specified by your google-services.json. Multi-flavor multi-build type google-services.json support has been available since plugin version 2.1.0 [1]

提交回复
热议问题