Creating a Tracking Pixel using Google Analytics v4 Measurement Protocol - google-analytics

I'm trying to create a tracking pixel using Google Analytics 4. From what I've read in the docs, you can only send a POST to create events. Here is an example:
curl --request POST \
--url 'https://www.google-analytics.com/mp/collect?api_secret=XXXXXXXXXX&measurement_id=G-XXXXXXXX' \
--header 'Content-Type: application/json' \
--data '{
"client_id": "555",
"events": [{
"name": "test_event",
"params": {
"session_id": "123",
"engagement_time_msec": "100"
}
}]
}'
This of course works. However, I want to create a tracking pixel that I can use to track things like email opens via an HTTP GET (via the call from the <img />'s src). With universal google analytics, this is done via:
<img src="https://www.google-analytics.com/collect?v=1&tid=G-XXXXXX&cid=555&t=event&ec=email&ea=open&dp=%2Femail%2Ftest&dt=test" alt="" height="1" width="1">
Am I missing something here or is it no longer possible to create a tracking pixel like the one above, but for GA v4?
I even found a thread on google's support page for this but no responses and has been locked.
I did try just adding a pixel like so, but no luck:
<img src="https://www.google-analytics.com/collect?v=4&tid=G-XXXXXXXX&cid=555&t=event&ec=email&ea=open&dp=%2Femail%2Ftest&dt=test" alt="" height="1" width="1">
I also tried using https://www.google-analytics.com/mp/collect in the img src, but http get is not allowed for that endpoint so it just errors out.

The Measurement Protocol is designed for use server side to send events. No pixel is used, just a POSTed message with a secret key. Note the key is secret, so should never be used on the client side.
If you are client-side on an HTML page, then you should use the normal gtag to send events.

Related

Are projections no longer working for /posts in the LinkedIn API 202301

We are fetching all posts by author in the LinkedIn Rest API. We are using a projection to enrich the author with things like name and logo. Here is the query:
curl "https://api.linkedin.com/rest/posts?author={MY_ORG}&q=author&count=50&projection=(elements(*(*,author~(vanityName,localizedName,logoV2(*,cropped~:playableStreams(*,elements*(identifiers*(identifier))))))))" \
-H "LinkedIn-Version: 202212" \
-H "Authorization: .."
This works fine, however if I change to LinkedIn-Version: 202301 I get this response:
{
"status": 400,
"code": "ILLEGAL_ARGUMENT",
"message": "projection parameter is not allowed for this endpoint"
}
Is this documented anywhere? How do I get the author's details instead?
You could look at the returned author field and determine if it is of the format:
PersonURN: /^urn:li:person:[a-z0-9]+$/i
Organization urn: /^urn:li:organization:[0-9]+$/
For organizations use the organization lookup API You cannot use the organization endpoint for it.
For persons use the profile API

Anti-Scraping bypass?

Helllo,
I'm working on a scraper for this page : https://www.dirk.nl/
I'm trying to get in scrapy shell the 'row-wrapper' div class.
If I enter response.css('row-wrapper'), it gives me some random results, I think an anti scraping system is involved. I need the hrefs from this class.
Any opinions on how can I move forward ?
We would need a little bit more data, like the response you receive and any code if it's already set up.
But from the looks of it, it can be multiple things ( from 429 Response blocking the request because of the rate limit to sites internal API XHR causing data to not be rendered on page load etc. ).
Before fetching any website for scraping reasons, try curl, postman or insomnia software to see what type of the response are you going to receive. Some special servers and website architectures require certain cookies and headers while some don't. You simply have to do this research so you can make your scraping workflow efficient.
I ran curl https://www.dirk.nl/ and it returned data that's generated by Nuxt framework. In this case that data is unusable since Nuxt uses it's own functionality to parse data.
Instead, the best solution would be not to get the HTML based data but API content data.
Something like this:
curl 'https://content-api.dirk.nl/misc/specific/culios.aspx?action=GetRecipe' \
-H 'accept: application/json, text/plain, */*' \
--data-raw '{"id":"11962"}' \
--compressed
Will return:
{"id":11962,"slug":"Muhammara kerstkrans","title":"Muhammara kerstkrans","subtitle":"", ...Rest of the data
I don't understand this language but from my basic understanding this would be an API route for recipes.

20 second Vimeo API calls with WordPress integration

We have a WordPress custom build and have integrated the Vimeo API to pull videos through to the website.
The setup is working but the API calls are taking 20 seconds. We have tested using Postman and they only take 1-2 seconds.
Is there a solution to this?
Use the fields parameter on your requests to tell the API to only return the metadata needed for your application. Because Vimeo API responses can be quite large, especially when retrieving a list of videos, the fields parameter can significantly reduce the size of the response, and subsequently increase response time.
For example, let's say you're making a request to get the last 10 videos you uploaded. The request would look like this:
curl -X GET https://api.vimeo.com/me/videos?page=1&per_page=10
-H 'Accept: application/vnd.vimeo.*+json;version=3.4'
-H 'Authorization: bearer [token]'
The response would return the full and complete video objects for 10 videos, which can be quite large. However if you only need some of the metadata in the response, such as the video's name, description, and its link on vimeo.com, then the same request with the fields param will look like this:
curl -X GET https://api.vimeo.com/me/videos?page=1&per_page=10&fields=uri,name,description,link
-H 'Accept: application/vnd.vimeo.*+json;version=3.4'
-H 'Authorization: bearer [token]'
The fields parameter is documented here: https://developer.vimeo.com/api/common-formats#json-filter

Clarifai API and cURL?

I'm following Clarifai's guide to make a cURL request and get the tags related to the image.
In the guide it says that I can do either this:
curl "https://api.clarifai.com/v1/tag/?url=https://samples.clarifai.com/metro-north.jpg" \
-H "Authorization: Bearer {access_token}"
or this:
curl "https://api.clarifai.com/v1/tag/" \
-X POST --data-urlencode "url=https://samples.clarifai.com/metro-north.jpg" \
-H "Authorization: Bearer {access_token}"
So what I do is that I type in the access token that I get when I create a new application and I change the link of "samples.clarifai.com" for a random link of a random image, but every time I want to do this I get the following message on terminal:
{"status_code": "TOKEN_INVALID", "status_msg": "Token is not valid. Please use valid tokens for a application in your account."}
Any idea why I keep getting this eben though my access token is right?
Thanks!
Just so there can have an official answer for this but Marcus Müller is totally right.
You should be sure to remove the braces with the Bearer access token. But you still want to be sure everything else is fine. This does assume though that you have generated a proper access token either by the Developer Documentation or within your Applications page once you have logged in.

Translating from cURL to straight HTTP requests

What would the following cURL command look like as a generic (without cURL) http request?
feedUri="https://www.someservice.com/feeds\
?prettyprint=true"
curl $feedUri --silent \
--header "GData-Version: 2"
For example how could such an http request be expressed in the browser address bar? Partucluarly, how do I express the --header information if I were to just type out the plain http request?
I don't know of any browser that lets you specify header information in the address bar. I believe there are plug-ins that let you do this, but I don't have any experience with them.
Here is one for firefox that looks promising:
https://addons.mozilla.org/en-US/firefox/addon/967
Basically what you want to do is not a standard browser feature.

Resources