cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to - Google Analytics 4 for Experiences

David_Imboden
3-Visitor

How to - Google Analytics 4 for Experiences

Hello 👋 

I was referring to the excellent article from "jmikesell" to implement Google Analytics. Sadly with Google Analytics version 4, lots of changes where made and I have to find new ways to link a Vuforia Studio Experience to GA.

 

So first you have to declare / init the GA 

 

var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src="https://www.googletagmanager.com/gtag/js?id=G-YOUR-GA-ID";
document.head.appendChild(s);
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-YOUR-GA-ID');

// declare as many events as you need.
gtag('event', 'my_action_name');

 

 

 

 

Please replace "G-YOUR-GA-ID" with your. GA id. Then you can set the gtag where you need to call them :

 

$scope.myAction = function() {
  // doing some stuff
  gtag('event', 'my_action_name');
}

 

Then you will see your tag in your GA account. Hope it helps. 

0 REPLIES 0
Top Tags