Solved

addUserProperties API through Google Tag Manager

  • 20 October 2023
  • 1 reply
  • 56 views

Badge

Hey all, 

I’m looking to use Google Tag Manager with the Heap addUserProperties API to attach pieces of info to users like buying stage, domain, etc. via another source I’ve gathered through another tag. 

However, I’m not sure when to call this API or how often within Google Tag Manager. Is it best practice to call the API in the same JS script that loads heap directly after the heap.load function? Or do I need to set up another tag for the API call? Either way, it seems like this API call will fire at least once per page, which I am not sure is best practice. 

Any help here is much appreciated. Thanks! 

icon

Best answer by dlad 8 November 2023, 23:36

View original

1 reply

Userlevel 4
Badge +2

Hi! Great question. You can fire the addUserProperties() API call in either manner: bundled below the Heap install snippet, OR as its own tag. The important factor, no matter which choice you make, is that the data you are sending within the API call is loaded and available before the Heap API call is made. Otherwise, you’ll be sending null. Perhaps that will best inform where to place the API call.

It’s no problem at all to make the API call once per page, and there is no penalty or overhead for redundant API calls (that doesn’t mean make 1,000 in a row! lol. One per page is totally fine). In fact, redundancy has some advantages, for example if for whatever reason an API call fails or is missed on one page, it will be picked up on the subsequent page.

Reply