Everything you need to monitor your website traffic, understand user behavior and measure ad conversions is here. Google Analytics 4 (GA4) Predict the future with, Google Tag Manager (GTM) Put an end to code confusion with.
In this guide; Installation on PHP and WordPress sites, DataLayer You will find (Data Layer) logic, e-commerce tracking and Eka Sunucu's professional installation services.
New generation data analysis supported by artificial intelligence.
Manage all tracking codes without writing code.
Selling, adding to cart and payment steps.
Google Ads and Meta Pixel integration.
Many users confuse these two tools. Here's the simple and clear distinction:
REPORTING TOOL
MANAGEMENT TOOL
Choose the method that suits your platform
Insert the codes you received from your Google Tag Manager account as follows:
INTO <HEAD> (To the top)<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
<BODY> IMMEDIATELY AFTER THE OPENING TAG
<!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) -->
If you are not going to use GTM, you can use this code <head> Add between tags:
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
header.php Open the file and </head> Paste your code just before the tag. (It can be deleted when the theme is updated, use Child Theme).When static tracking codes are insufficient (for example: when you want to send the logged in user's ID or cart amount to Google) DataLayer comes into play.
By printing the data (Session, Database) on the PHP side to the page as a JavaScript variable, you enable GTM to read this data.
<head>
<script>
// DataLayer dizisini başlat
window.dataLayer = window.dataLayer || [];
// PHP'den gelen verileri DataLayer'a it (push)
window.dataLayer.push({
'user_id': '<?php echo $_SESSION["user_id"]; ?>', // User ID Takibi
'user_role': '<?php echo $user_role; ?>', // Üye Tipi
'page_type': 'product_detail',
'ecommerce': {
'currency': 'TRY',
'value': <?php echo $product_price; ?>,
'items': [{
'item_id': '<?php echo $product_id; ?>',
'item_name': '<?php echo $product_name; ?>'
}]
}
});
</script>
<!-- GTM Kodu Buraya Gelecek (DataLayer'dan SONRA) -->
</head>
Measure your data correctly, don't waste your budget
Basic tracking settings for small businesses and blogs.
Measure sales, revenue and product performance in detail.
Let's check the accuracy of your current setup.
Frequently asked questions about data tracking
No, Google has completely shut down Universal Analytics. Now only Google Analytics 4 (GA4) collects data. It is imperative that you migrate your old properties to GA4.
No, on the contrary, it speeds it up. GTM bundles all tracking codes (Facebook, Ads, GA4) into one asynchronous script. In this way, the browser makes a single request instead of loading each code separately.
DataLayer is a bridge between your website (PHP/Back-end) and GTM. "What is the price of this product?", "Is the user a member?" It is the healthiest way to transfer information such as to GTM and from there to advertising platforms.
By default, GA4 anonymizes IP addresses, but you must obtain consent from the visitor for the use of cookies (Cookie Consent). Legal compliance can be ensured by setting "Consent Mode" via GTM.
Turn your data into light. Make your installation error-free with Eka Sunucu expertise and use your advertising budget efficiently.