Forum Replies Created

  • For authentication purposes, you don’t inherently need to manually pass an access token when using Google APIs on the server. The JSON config file that you have is used to auto-authenticate your client. The PHP client library for Google APIs uses a service account key file (JSON) referenced in the GOOGLE_APPLICATION_CREDENTIALS environment variable to automatically handle the OAuth 2.0 process. When you pass this environment variable, the client library takes care of generating the access token behind the scenes and using it in subsequent API calls. In your case, make sure your service account has the necessary permissions in Google Analytics and that the path in the GOOGLE_APPLICATION_CREDENTIALS variable correctly points to your JSON key file.

  • Morgan

    Member
    7 July 2023 at 6:06 pm in reply to: Troubleshooting Browser Back Function with gtag.js in GA4

    It seems like your scripts are interfering with the browser’s ‘back’ button function. Maybe they’re adding extra history states or changing the URLs. Try to debug your scripts line by line checking how they interact with browser history. Thankfully, this problem isn’t happening when a JS plugin is installed in the browser, so the issue might be linked with how your script gets processed without the plugin.

  • Yes, it is possible to manage and list your Google Tag Manager (GTM) tags and triggers using Java. Google provides the Tag Manager API which allows you to access and update your GTM configuration programmatically. You can use this API to create, read, update, and delete tags, triggers, and other configurations. Google provides client libraries for various languages, including Java. You can leverage these libraries to interact with your GTM account using Java programming language. You can get started by checking out the user guide, reference documentation, and sample code provided in the Google Tag Manager API Java Client Library.

  • Hey there! Hmmm, it appears there might be an odd bug causing this confusion. You definitely shouldn’t be seeing a 500 error if your ‘last_monday’ and ‘last_sunday’ inputs are accurately set. This merits some attention for sure.

    For quick help, have you tried using the raw_json parameter with your request? This assumes you have valid JSON data for your request. Here is how you could proceed:

    `R
    raw <- '{"dimensions":[{"name":"itemId"},{"name":"nthWeek"}],"metrics":[{"name":"averagePurchaseRevenue"},{"name":"itemPurchaseQuantity"},{"name":"itemRevenue"}],"dateRanges":[{"startDate":"2022-08-01","endDate":"2022-08-07"}]}'
    ga_data(propertyId = property_id, raw_json = raw)
    `

    As a result of doing this, API requests will be generated with raw JSON and produce a series of outputs, including items like ‘itemId’, ‘nthWeek’, ‘averagePurchaseRevenue’, among others.

    This should help you bypass the issue for now. And at the same time, could you flag this anomalous bug on the GitHub page of the project? The developer community would definitely appreciate it!

  • Morgan

    Member
    25 May 2023 at 8:19 am in reply to: Utilizing GA4 Data Stored in BigQuery with PowerBI Integration

    Based on the format of your current table in BigQuery and your desired table, it seems like you are trying to unnest JSON into individual columns. To achieve this, you will need to use some SQL functionality.

    Firstly, extracting JSON data into columns in BigQuery can be done using the JSON_EXTRACT_SCALAR function in SQL. The function requires two string-type parameters – the JSON string and the JSONPath query.

    For instance, you can create a view in BigQuery that extracts the parameters from device, geo, and traffic_source and represents them as separate columns. The code will look similar to this:

    SELECT
    event_name,
    JSON_EXTRACT_SCALAR(device, ‘$.v.f[0].v’) AS device_type,
    JSON_EXTRACT_SCALAR(device, ‘$.v.f[1].v’) AS device_brand,
    — Add more fields as needed with correct path to JSON fields
    JSON_EXTRACT_SCALAR(geo, ‘$.v.f[0].v’) AS geo_continent,
    JSON_EXTRACT_SCALAR(geo, ‘$.v.f[1].v’) AS geo_sub_continent,
    — Add more fields as needed
    FROM your_table;

    In the sample SQL code, event_name is a given column, the other columns are extracted from the JSON inside device and geo.

    Please note that this assumes a consistency in the order of the nested JSON data. If the order isn’t consistent, you might run into issue. Also, you need to replace ‘your_table’ with the name of your table.

    Once you have this setup, querying the data in PowerBI should be pretty straightforward. From PowerBI’s navigation menu, go to ‘Get Data’ and select BigQuery as your data source. Then, use Power BI’s interface to write the SQL query, or select the view you created earlier, and load the data.

    Finally, JSON data and its extraction can prove tricky and you might encounter some adjustments to be made according to the specific structure of your JSON data. But this should provide a decent start. If there are still issues, it might be worth investing time in understanding JSON structure more profoundly or consider reaching out for expert help.

  • Morgan

    Member
    3 May 2023 at 11:55 am in reply to: . Track Custom Parameters for Click Events in GA4

    In Google Analytics 4, you can indeed use a large number of custom event parameters, which can be beneficial for detailed usage tracking. The downside you discovered is that too many custom events can convolute and overwhelm your ‘Event’ reporting. In GA4, defining a custom ‘click’ event different from the automatic click tracking performed by GA4 could indeed result in increased data, as GA4 might track both. Instead of creating custom events for each click, consider utilizing event parameters to differentiate between various clicks. However, the information you provide via parameters like ‘event_label’ might not show up as clearly in default GA4 reports. You may need to use the ‘Analysis Hub’ to customize your reports and extract the desired insights. While this might require a bit of setting up initially, it should offer a cleaner solution in the long run. It is highly advisable to take time and consider the best strategy for tracking events that suits your needs.

  • Yes, your current use of google-api-php-client could potentially be affected. The notice you’ve linked to is indicating Google’s plan to phase out the universal analytics and replace it with Google Analytics 4. Any project relying on Google’s universal analytics might face issues or stop functioning correctly once the retirement is completely implemented. Therefore, you’re advised to upgrade your dependencies and adjust your project to utilize Google Analytics 4 to ensure future compatibility. However, Google usually provides a transition period, so you should have ample time to make the necessary changes.

  • Morgan

    Member
    11 March 2023 at 11:37 am in reply to: Tracking Discrepancy: GA4 Measurement API's Summation Issue

    The discrepancy in total transaction value in GA4 when using the measurement-api to send e-commerce transactions can be due to numerous reasons. One could be a delay in data processing or reporting on GA4. There could also be a difference between how GA4 and Analytics Universal handle or interpret transaction data. Data filters, sampling, or discrepancies between server and browser times could also contribute to the difference. Furthermore, discrepancies may be caused by differences in currency conversion rates if your transactions involve multiple currencies. Other potential issues could be related to how refunds or chargebacks are reported, or even how different platforms classify and report on unique versus repeat customers. It might be beneficial to involve an analytics expert or Google Support to get to the bottom of this.

  • Morgan

    Member
    6 December 2022 at 7:35 am in reply to: Discrepancy in User Counts between GA4 and BigQuery

    The discrepancy between your Bigquery data and GA4 data for the same parameters could be due to multiple reasons. It could be from how GA4 segments and counts active users, as the methodologies may be different from yours. Check how active users are defined in GA4– they might be basing it on different parameters for activity. The issue could also be from the time zones. BigQuery and GA4 might be working on different time zones, causing variations in the count for the same day. Another issue could be related to data processing–maybe GA4 processes the data in real-time and BigQuery with a delay. Lastly, ensure that all the data is correctly synced from GA4 to BigQuery. It’s possible that BigQuery is not receiving all the data from GA4.

  • Morgan

    Member
    15 August 2022 at 11:40 am in reply to: Discrepancy between GA4 purchase event revenue and order value

    Ah, you see, Google Analytics has a bit of a quirk. Even if you set your property or view to your own local currency, Analytics still does a conversion whenever it processes a hit for any currency that isn’t USD. What’s more, it does this conversion all over again whenever you generate a report.

    So, even if everything else is in order – your currency settings, your data layer, Shopify – those little differences you’re seeing might just be due to fluctuations in the daily exchange rate. It’s a bit like how the cost of a foreign holiday can go up or down because of changes in the exchange rate.

    You no need to worry too much, these differences are usually negligible!

  • Based on your description, it seems like your view_item event is not being fired, hence isn’t showing up in GA4 Debug View or in the Chrome Dev Tools network tab.

    If your script is correctly placed and there’s no error in the console, it might be a timing issue. Sometimes, the gtag function you’re calling isn’t fully loaded when you’re trying to send the view_item event.

    You might consider using the function window.dataLayer.push() instead of gtag(). The dataLayer.push() function will queue your events and commands until gtag.js is completely loaded and ready to send them. Here’s how you could modify your script to utilize this function:

    `javascript
    window.dataLayer = window.dataLayer || [];
    window.dataLayer.push({
    event: “view_item”,
    ecommerce: {
    currency: “USD”,
    value: parseFloat(2.4),
    items: [{
    item_id: “9781645072485”,
    item_name: “Alongside Jesus: Devotions for Teenagers”,
    currency: “USD”,
    discount: parseFloat(16.99),
    item_brand: “Drew Hill”,
    price: parseFloat(2.4),
    quantity: 1,
    item_category: “Teen/Teen Books”
    }]
    }
    });
    `
    If you’re still encountering issues after this, there might be other aspects of your setup that need to be reviewed. You may want to check to ensure that your tracking ID is correctly configured or that there isn’t something else in your overall tag setup preventing the event from being sent.