We implemented AMP to our site a couple of months ago. We're tracking visits correct in Google Analytics but the speed dimensions are empty, we have no sample pages measured.
How can I get the load time in amp pages?
In amp-analytics config I put 'site_speed_sample_rate' => 100 in order to track all the pages.
self::$triggers['trackPageview'] = [
'on' => 'visible',
'request' => 'pageview',
'vars' => [
'account' => $this->environment->getCodigoAnalitics(),
'site_speed_sample_rate' => 100
]
];
I expect to get the load timings but all i've got is 0s in all amp pages.
I may be late but hope someone might find it useful. Various AMP features allow variables to be used inside of strings and substituted with the corresponding actual values. ${contentLoadTime} is one of them.
"triggers": {
"trackGA": {
"selector": "amp-layout",
"on": "visible",
"request": "event",
"vars": {
"eventAction" : "ContentLoadTime",
"eventCategory": "${contentLoadTime}"
}
}
}
link to the whole list : https://github.com/ampproject/amphtml/blob/master/spec/amp-var-substitutions.md
Related
I am having problems with Elastic Search. It seams the search term is being isolated in search results.
We have a large subtitle database that was indexed using Elastic Search.
It seams however, that our searches prioritize search results where the search term is isolated.
Ie: the search for "Eat" produces:
Oh, skydiving. // Skydiving. // Oh, I got that one. // Eating crazy. // Eating, eating. // Just pass, just pass. // You guys suck at that. // What was that? // Synchronized swimming
AND
it's my last night so we're gonna live // life like there's no tomorrow. // - I think I'd just wanna, // - Eat. // - Bring all the food, // whether it's Mcdonald's, whether it's, // - Ice cream.
We need to INSTEAD prioritize search results where the searchTerm is found WITHIN the sentence, rather than just on its own.
I need help determining what needs to be fixed - The Mapping, the filters, the tokenizers etc.
Here are my settings:
static public function getSettings(){
return [
'number_of_shards' => 1,
'number_of_replicas' => 1,
'analysis' => [
'filter' => [
'filter_stemmer' => [
'type' => 'stemmer',
'language' => 'english'
]
],
'analyzer' => [
'text_analyzer' => [
'type' => 'custom',
"stopwords" => [],
'filter' => ['lowercase', 'filter_stemmer','stemmer'],
'tokenizer' => 'standard'
],
]
]
];
}
and here are my mapping:
https://gist.github.com/firecentaur/d0e1e196f7fddbb4d02935bec5592009
And here is my search
https://gist.github.com/firecentaur/5ac97bbd8eb02c406d6eecf867afc13c
What am I doing wrong?
This behavior must be caused by the TL/IDF algorithm.
If a query match a field, it will be more important if their is few words in the field.
If you want to adapt this to your use case, you can use a function_score query.
This post should help you to find a solution.
How can I boost the field length norm in elasticsearch function score?
I'm trying to update the on-hand of a variation using the inventory/batch-change API. My system is the source of record for the item on-hand so I'm posting a PHYSICAL_COUNT to the variant. Everything looks fine if you drill down into the stock section of the variant; however, the main item dashboard has a - and the variation shows none in the stock section. I'm not sure what the issue is because when I post thePHYSICAL_COUNT I also set the state=IN_STOCK.
Here is the json used to update inventory
API URL :https://connect.squareup.com/v2/inventory/batch-change
{
"idempotency_key": "XXXXXXXX",
"changes": [
{
"type": "PHYSICAL_COUNT",
"physical_count": {
"catalog_object_id": "XXXXXXXX",
"state": "IN_STOCK",
"location_id": "XXXXXXXX",
"quantity": "3",
"occurred_at": "2020-04-20T15:02:00Z"
}
}
],
"ignore_unchanged_counts": true
}
Square Stock None
Square Stock
There is a known issue around this, when using the Inventory API and looking at the dashboard it will be out of sync unless you update the item variation in the Catalog API to use individual location_overrides (regardless if it's going to be available in every location). This field lives in the CatalogObject->item_variation_data->location_overrides (https://developer.squareup.com/reference/square/catalog-api/upsert-catalog-object#modal__property-item_variation_data).
I am trying to save a google drive file with custom properties, but its not working and due to the very poor documentation of the Google API, i am struggeling with this. Here is my code so far:
$g = new FileCtrl();
$fileMeta = new Google_Service_Drive_DriveFile();
$fileMeta->name = $file['name'];
$fileMeta->parents = [$g->googleDriveFolderId];
$fileMeta->appProperties = (object)['lead_id'=>$file['lid'], 'sales_package_id'=>$file['pid'], 'user_id'=>$user->uid];
//$fileMeta->size = $file['size'];
$fileData = array(
'data' => $fileContent,
'mimeType' => $file['media_type'],
'uploadType' => $file['multipart'],
);
//create file in google drive
$res = $g->client->files->create($fileMeta, $fileData);
It is not returning an error and the event is saved, but without the custom properties!?
You are probably looking for the properties in the returned file resource.
The reason they aren't there is that Drive only returns a small number of the file properties (name, mime type, id). If you want to see the full file resource you need to include fields=* in the request. So a correct request would look something like
POST https://content.googleapis.com/drive/v3/files?fields=*
I don't know the PHP library, so you'll need to figure that bit out. It will be something like
'fields' => '*',
I just tested this.
Request:
{
"name": "Linda Test",
"mimeType": "application/vnd.google-apps.document",
"appProperties": {
"TestingId": "1"
}
}
Response:
{
"kind": "drive#file",
"id": "1mhP2EW4Kbl81F5AuJ4zJ2IPoeI56i_Vd5K-dfGJRj6Y",
"name": "Linda Test",
"mimeType": "application/vnd.google-apps.document"
}
Do a file.get to check the file metadata.
{
"kind": "drive#file",
"id": "1mhP2EW4Kbl81F5AuJ4zJ2IPoeI56i_Vd5K-dfGJRj6Y",
"name": "Linda Test",
"mimeType": "application/vnd.google-apps.document",
"starred": false,
"trashed": false,
"explicitlyTrashed": false,
"parents": [
"0AJpJkOVaKccEUk9PVA"
],
"appProperties": {
"TestingId": "1"
},
...
}
I suggest you check your uploaded file using the File.get method after its returned to be sure that it was added. To my knowledge there is now way to see these added fields via the Google drive website interface. If after ruining a file.get you still find that it wasn't uploaded i suggest you log this as a bug with the Google APIs PHP client library team. This works with raw rest requests it could be an issue with the library.
I am trying to do application specific places search with google place api. Here is how I am adding a place:
Request:
{
"location": {
"lat": 37.760538,
"lng": -121.900879
},
"accuracy": 50,
"name": "p2p",
"types": ["other"]
}
I get success response as shown below:
Response:
{
"id" : "dfe583b1ac058750cf524f958afc5e82ade455d7",
"place_id" : "qgYvCi0wMDAwMDBhNWE4OWU4NTMzOjgwOGZlZTBhNjI3OjBjNTU1OTU4M2Q2NDI5YmM",
"reference" : "CkQxAAAAsPE72V-jhHUjj6vPy2HdC__2MhAdXanL6mlFBA4bcayRabKyMlfKFiah7U2vkoCj1P_0w9ESFSv5mfDkyufaZhIQTHBHY_jPGRHEE3EmEAGElhoUXTSylMslwHSTK5tYdstW2rOZKbw",
"scope" : "APP",
"status" : "OK"
}
When I search for this place using radar search, I get ZERO_RESULTS.
Request:
https://maps.googleapis.com/maps/api/place/radarsearch/json?key=key&radius=5000&location=37.761926,-121.891856&keyword=p2p
Response:
{
"html_attributions": [ ],
"results": [ ],
"status": "ZERO_RESULTS"
}
Is there something that I am doing the right way? Please help.
Thanks & Regards,
--Rajani
Your scope is "APP". That means you can access it (via PlaceID) from the application that created the entry only. If the location passes Google's moderation process, then it will gain scope "GOOGLE" and be accessible from the general searches.
scope — Indicates the scope of the place_id. The possible values are:
APP: The place ID is recognised by your application only. This is because your
application added the place, and the place has not yet
passed the moderation process.
GOOGLE: The place ID is available to other applications and on Google Maps.
Note: The scope field is included only in Nearby Search results and
Place Details results. You can only retrieve app-scoped places via the
Nearby Search and the Place Details requests. If the scope field is
not present in a response, it is safe to assume the scope is GOOGLE.
See: https://developers.google.com/places/documentation/search
In response to my question here, I was referred to "jquery datatables plugin" which (I think) I found, but which link is not allowed here for some reason.
However, although I added the requisite libraries (one jQuery and one CSS) as "External Resources" to my jsfiddle here and am using precisely the same HTML and jQuery as on their sample page:
$(document).ready(function() {
$('#example').dataTable( {
columnDefs: [ {
targets: [ 0 ],
orderData: [ 0, 1 ]
}, {
targets: [ 1 ],
orderData: [ 1, 0 ]
}, {
targets: [ 4 ],
orderData: [ 4, 0 ]
} ]
} );
} );
...running it doesn't seem to make the table sortable.
What am I missing?
I was also referred to "jQuery Table Sorter" but it doesn't seem to be available on a CDN, and thus would not be available on a jsfiddle page.
UPDATE
Actually, the aforementioned "jQuery Table Sorter" does seem to be available on a CDN, as Jason points out at the other question but, now that I've gotten the other working, I reckon I'll stick with it.
My bad: in my ignorance of CDN reference standards, I assumed the leading double whacks were unnecessary and removed them when adding to the External Resources. IOW, instead of pasting this:
cdn.datatables.net/1.10.0/js/jquery.dataTables.js
...it needs to be this:
//cdn.datatables.net/1.10.0/js/jquery.dataTables.js
On reinstating the double-whacks (which looked like they were being commented out to me), it all runs fine now here