This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'amp_post_template_head', 'amp_post_template_add_analytics_js' ); | |
function amp_post_template_add_analytics_js( $amp_template ) { | |
$post_id = $amp_template->get( 'post_id' ); | |
?> | |
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script> | |
<?php | |
} | |
add_action( 'amp_post_template_footer', 'xyz_amp_add_analytics' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Edit AMP Plugin file: amp/includes/class-amp-post-template.php | |
/* | |
Change this bit of code to the below uncommented code: | |
$image_metadata = $this->get_post_image_metadata(); | |
if ( $image_metadata ) { | |
$metadata['image'] = $image_metadata; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Edit the class-amp-post-template.php file, either via FTP or within your WordPress Dashboard (go to Plugins > Editor and then select “AMP”) and change this: | |
if ( $site_icon_url ) { | |
$metadata['publisher']['logo'] = array( | |
'@type' => 'ImageObject', | |
'url' => $site_icon_url, | |
'height' => self::SITE_ICON_SIZE, | |
'width' => self::SITE_ICON_SIZE, | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("igraph") | |
# Swap out path to your Screaming Frog All Outlink CSV. For Windows, remember to change backslashes to forward slashes. | |
links <- read.csv("C:/Documents/screaming-frog-all-outlinks.csv", skip = 1) # CSV Path | |
# This line of code is optional. It filters out JavaScript, CSS, and Images. Technically you should keep them in there. | |
links <- subset(links, Type=="AHREF") # Optional line. Filter. | |
links <- subset(links, Follow=="true") | |
links <- subset(links, select=c(Source,Destination)) | |
g <- graph.data.frame(links) | |
pr <- page.rank(g, algo = "prpack", vids = V(g), directed = TRUE, damping = 0.85) | |
values <- data.frame(pr$vector) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("igraph") | |
internallinks <- read.csv("C:/Users/username/folder/screamingfrog-all-inlinks.csv") | |
g <- graph.data.frame(internallinks) | |
pr <- page.rank(g, algo = "prpack", vids = V(g), directed = TRUE, damping = 0.85) | |
values <- data.frame(pr$vector) | |
write.csv(values, file = "output-pagerank.csv") | |
map <- function(x, range = c(0,1), from.range=NA) { | |
if(any(is.na(from.range))) from.range <- range(x, na.rm=TRUE) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# library imports | |
import pandas as pd | |
from bokeh.io import output_notebook, show | |
from bokeh.plotting import figure, output_file, ColumnDataSource | |
from bokeh.models import HoverTool, BoxAnnotation, BoxSelectTool, BoxZoomTool, WheelZoomTool, ResetTool | |
from bokeh.resources import CDN | |
from bokeh.embed import file_html | |
# Import csv into pandas dataframe, direct to KNIME version to follow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires pandas. For Windows users, I recommend installing the Anaconda Python distirbution. | |
# Requires the pytrends library. To install, run "pip install pytrends". | |
from pytrends.pyGTrends import pyGTrends | |
import time | |
import os | |
from random import randint | |
import pandas as pd | |
# Add your Gmail username to the google_username variable and your Gmail password to the google_password variable. | |
google_username = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(igraph) | |
map <- function(x, range = c(0,1), from.range=NA) { | |
if(any(is.na(from.range))) from.range <- range(x, na.rm=TRUE) | |
## check if all values are the same | |
if(!diff(from.range)) return( | |
matrix(mean(range), ncol=ncol(x), nrow=nrow(x), | |
dimnames = dimnames(x))) | |
## map to [0,1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
import csv | |
import os | |
# For details about AMPBench and the API: | |
# https://github.com/ampproject/ampbench | |
urlinput = os.path.join(os.path.dirname(__file__), input('Enter input text file: ')) | |
urls = open(urlinput, "r") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://www.simoahava.com/analytics/google-analytics-client-id-amp-pages/ | |
// REST API for GTM container | |
add_action( 'rest_api_init', function() { | |
register_rest_route( | |
'amp-gtm', | |
'/amp.json', | |
array( | |
'methods' => 'GET', | |
'callback' => 'retrieve_gtm_json', | |
) |
OlderNewer