AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

4.8K members online now
4.8K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
Guide Me

Setting custom variables in a server-side script

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I've configured GTM/Analytics to track a host of transaction variables such as cost of goods, shipping cost estimates, and discounts to allow us to build a profitability dashboard in Analytics.  It is pure awesomeness and gives our paid search folks a very valuable tool for measuring ROI.  Now, to take it to the next level, I want to upload our daily fixed overhead into a custom metric so we can really track true profit.  However, we want it to be run by a PHP server-side cron script every day, so javascript isn't really an option.  Right now all the data is tied to transaction and product data sets and this would technically be a stand-alone data object that is posted each day.  This is new territory for me, so I'm hoping someone can point me to an example of such a thing.  Looking at the examples for custom metrics, it seems that the server-side equivalent of something like this is what I'd want:


ga('send', 'event', 'category', 'action', {
'metric19': 24.99

I would chose the number of the metric to be the next available metric index in Analytics and would set it as a Hit scope?  

Re: Setting custom variables in a server-side script

Participant ✭ ✭ ✭
# 2