- Matelso offers a standard integration for Google Analytics 4. In the standard integration, however, some values are fixed, such as the Google Client ID. If you want to use a different value or feature from the Custom Push configuration, we have instructions for you here.
- Create Custom Push
- Add matelso GA4 Snippet
- ReferenceError: gtag is not defined
Matelso offers a standard integration for Google Analytics 4. In the standard integration, however, some values are fixed, such as the Google Client ID. If you want to use a different value or feature from the Custom Push configuration, we have instructions for you here. #
This integration is build upon the measurement protocol of google analytics 4: Measurement Protocol
Google introduced “Google Analytics 4”. In version 4 some reforms are to be minded. Among other things, there will no longer be UA IDs in the new version, but data streams and measurement IDs.
1. The new version 4 is now also supported as a standard integration in our matelso systems. With a custom push, however, you get more configuration options. The prices for this can be seen in the contract and in the sidebar under Integrations 2.0.
2. This article is intended as a support service. Therefore, the contents of this article cannot be covered by the standard support and any support provided by matelso on this topic will be charged as a consulting service. Please contact service@matelso.com for this purpose.
3. The Measurement Protocol interface of Google Analytics 4 is still in a preview mode (alpha). This means that there may be major changes to this interface, which may also lead to incompatibility of existing integrations. This also applies to the content of this article.
Create Custom Push #
In this step, we set up a Custom Push that transfers the call data into GA4 using the Measurement Protocol.
In the example, we are setting up a custom push called “GA4 Custom Push” that will be sent as a POST call. We don’t set up a filter because we want to transfer every call.
Next, we set up which data should be transmitted. For this we select “POST” as HTTP method and add 2 GET parameters:
Now we enter the Measurement Id again and our API Secret. You can find/create those informations in Google Analytics 4:
Now we fill the POST body with the following content:
{
"client_id": "{{{{webData.googleAnalytics4.PLAEHOLDERFORYOURM-ID.client_id.attribution(LASTNOTEMPTY)}}”,
"events": [{
"name": "InboundCall",
"params": {
"action": "{{callData.status}}",
"label": "{{callData.aNumber.city}}",
"value": "{{callData.callDuration.timeSpanFormatter(TotalSeconds)}}",
"currency": "EUR"
}
}]
}
The parameters “action”, “label” and “value” are set to the following DDD Keys (identical to the standard Universal Analytics Push configuration):
This is only one example of possible parameters. The parameters can now be freely set and defined by you.
Destination of the push is Google Analytics:
We choose HTTPS as protocol.
Host: www.google-analytics.com
Port stays at 443.
Path: /mp/collect
The rest is kept as default since our authentication is via API secret and not via https.
The last thing we do is link our custom push to the pools. The data now flows into Google Analytics 4.Als letztes verknĂĽpfen wir unseren Custom Push mit den Pools. Die Daten laufen nun in Google Analytics 4 ein.
The following Steps are only necessary, if you don’t use the account functionality of the matelso control panel to save the API Secret and collect the GA4 Client ID.
Add matelso GA4 Snippet #
<script>
(function(){
var ga4PropertyId = 'G-';
function getGa4() {
if(mtls.loaded) {
gtag('get', ga4PropertyId, 'client_id', function (clientID) {
window[window.CallTrackingObject]("addCustomTrackingValues", { ga4ClientId: clientID });
});
} else {
setTimeout(getGa4, 150);
}
}
getGa4();
})();
</script>
Simply play out this script on the page after the matelso script. If the script is played out via a tag manager, then play out this script on the same pages.
In this script the variable ga4PropertyId must be set to the Measurement Id of the GA4 property.
After this variable is set correctly and the script is built on the page, it can push the GA4 ClientId into the matelso DataLayer and we have access to it in Integrations 2.0.
ReferenceError: gtag is not defined #
If this error message appears in the browser console, we add the following after the opening script tag (“<script>”) in the script shown under 1:
function gtag(){dataLayer.push(arguments);}