Google Tag Manager (GTM) bridge

Setup the Accengage Bridge for GTM

  1. Create (or use an existing) Firebase account.
  2. Go to the Google Tag Management (GTM) console.
  3. Create a GTM account - if you already have one, please go to step 4

    • Indicate an account name.
    • Select a country.
  4. Create your container:

    • Indicate its name.
    • Select your platform.
    • Choose the SDK version: Firebase.

Img

  1. Add the GTM dependency:

    • In your Podfile, add the following:

pod ‘GoogleTagManager'
  1. Add Accengage’s bridge:


  2. Go back to the GTM interface.
  3. Submit your container changes and Publish the container or Create a version.
  4. Download your container version.
  5. Add the downloaded container to your project:
Copy the downloaded file into a folder called container in the XCode project root (usually PROJECT_ROOT/container/GTM-XXXXXX.json).

  6. Preview your container. To be able to test your GTM modification before publishing. Google Tag Manager enables you to preview versions of your container by generating links and QR codes in the Google Tag Manager web interface and using them to open your application.


Preview container

To preview a container, generate a preview URL in the Google Tag Manager web interface:

  • Sign in to your Google Tag Manager account.
  • Select a mobile container.
  • Click Versions in the top navigation bar.
  • Click Actions > Preview on the container version you'd like to preview.
  • Enter your application's package name.
  • Click Generate begin preview link.

Img

Save this preview URL for later steps. 
To enable container previews, you must define the Google Tag Manager preview URL scheme in your project's property list. Under URL types of your application's property list file, register the following URL identifier and URL scheme:

URL identifier: your.package.name
URL scheme: tagmanager.c.your.package.name

Img

Your Application is now well configured to trigger the Accengage SDK methods on Firebase events. After that, you'll need to set up your tags on the GTM interface. Follow the next steps to understand how to create Tags.

Accengage action key

The Accengage GTM bridge has to be used with a key acc_action to define what action you want Accengage to do with your parameters. That key acc_action should be used with one of the following values :

  • track_event
  • track_lead
  • track_add_to_cart
  • track_purchase
  • set_udi
  • delete_udi
  • increment_udi
  • decrement_udi

As our tracking methods have some mandatory parameters, some methods will need some specific keys to work.

Create a Trigger

Want to know more about what is a GTM trigger? please follow this link GTM Tags are fired on triggers. Then you'll need to create triggers to send Accengage SDK actions. The conditions of your trigger depend on when you want the Accengage SDK action to be sent. We recommend to use the Event Name that is already tagged in your application, but you can use whatever you want.

Create a Tag

Want to know more about what is a GTM tag? please follow this link

TrackEvent

  1. Create a new Tag
  2. Add a previously created trigger: AccengageTrackEventTrigger in that case.
  3. Set the tag type with Function Call
  4. Indicate the classpath of the Accengage bridge in your application: ACCCustomTagProvider
  5. Add the acc_action key and fill the value with the Accengage SDK action you want to do. In that case, track_event.
  6. Then add the acc_event_id key with your event ID as a value.
  7. You can also add some personal key/value. All of them will be added as parameters in the Accengage trackEvent method.

Img

TrackLead

  1. Create a new Tag
  2. Add a previously created trigger: AccengageTrackLeadTrigger in that case
  3. Set the tag type with Function Call
  4. Indicate the classpath of the Accengage bridge in your application: ACCCustomTagProvider
  5. Add the acc_action key and fill the value with the Accengage SDK action you want to do. In that case, track_lead.
  6. Then add the two mandatory keys of a Lead, acc_lead_label, and acc_lead_value.
  7. Fill them with the appropriate values or variables.

Img

TrackAddToCart

  1. Create a new Tag.
  2. Add a previously created trigger : AccengageTrackAddToCartTrigger in that case
  3. Set the tag type with Function Call
  4. Indicate the classpath of the Accengage bridge in your application: ACCCustomTagProvider
  5. Add the acc_action key and fill the value with the Accengage SDK action you want to do. In that case, track_add_to_cart.
  6. Then add the mandatory keys for an Add To Cart, acc_cart_idacc_item_idacc_item_labelacc_item_categoryacc_item_currencyacc_item_price and acc_item_quantity.
  7. Fill them with the appropriate values or variables.

Img

TrackPurchase

  1. Create a new Tag.
  2. Add a previously created trigger: AccengageTrackPurchaseTrigger in that case
  3. Set the tag type with Function Call
  4. Indicate the classpath of the Accengage bridge in your application: ACCCustomTagProvider
  5. Add the acc_action key and fill the value with the Accengage SDK action you want to do. In that case, track_purchase.
  6. Then add the mandatory keys for a Purchase, acc_purchase_idacc_purchase_currency, and acc_purchase_total_price.
  7. Fill them with the appropriate values or variables.

Img

Update Device Information

There are two ways to use GTM to send an Accengage Update Device Information. Both of them have their own constraints and specificities. And both of them can be complementary.

Use Firebase Log Event

Like the other tracking methods, you can create a Tag to fire the Accengage updateDeviceInformation() method on a Firebase Log Event. That requires you to call a Firebase Log Event, instead of Firebase setUserProperty() method in your code to send an Update Device Information to Accengage immediately.

For that, you'll have to :

  1. Create a new Tag.
  2. Add a previously created trigger: AccengageUDITrigger for example.
  3. Set the tag type with Function Call.
  4. Indicate the classpath of the Accengage bridge in your application: ACCCustomTagProvider.
  5. Add the acc_action key and fill the value with the Accengage SDK action you want to do. There are four possible actions for updating device information in Accengage :

    • set_udi
    • delete_udi
    • increment_udi
    • decrement_udi
  6. Then add the keys you want to update in Accengage with the associated value.

Img

Use Firebase User Property

As expected, you may want to update Accengage device information on Firebase setUserProperty() method. At the moment, GTM triggers only fire when a Firebase Event occurs and all of the trigger conditions are true. That means you can create another Trigger for your Update Device Information action and add a condition for the a User Property in it. That trigger won't be immediatly fired after the Firebase setUserProperty() method, but after the next Firebase Event. For that, you'll have to:

  1. Create a new Tag.
  2. Create a new Trigger: AccengageUDITrigger for example.

    • You can use a user property already tagged in your application as trigger (or use a regex to match every value tagged in your application for a user property).
  3. Set the tag type with Function Call.
  4. Indicate the class path of the Accengage bridge in your application: AccCustomTagProvider.
  5. Add the acc_action key and fill the value with the Accengage SDK action you want to do. There are four possible action for updating device information in Accengage:

    • set_udi
    • delete_udi
    • increment_udi
    • decrement_udi
  6. Then add the keys you want to update in Accengage with the associated value.

When you add key or value, you may want to use the value passed as parameters in the Firebase event method. For that, you need to create a Variable in the GTM interface to retrieve your event parameters. Then you will have the possibility to use those variables in your Tags or others.

Want to know more about what is a variable? please follow this link.

Do not hesitate to have a look at the Google Tag Manager official documentation for iOS and Android to deeply understand the Accengage GTM bridge.