Excel实战技巧之—使用Excel添加监测

2018-05-15
  • 1124
  • 0

在做SEM工作当中,在我们进行关键词的拓词和账户的管理时,常常需要对URL进行新增或着修改。而很多客户在进行SEM推广时,都会在自己的网站内埋下监测代码,这需要我们在广告URL后面也添加上监测代码,才能监测到从搜索导入的流量转化情况。

一般客户常用的监测系统有GA、百度统计、友盟、growingio等。这些监测系统虽然内在功能有些许不一样,但大体的监测逻辑是大同小异的,今天笔者就以GA监测为例,讲述如何通过excel为关键词添加监测。

首先,添加监测时一定要理解具体的监测规则。如下图中GA监测中每一个格可以理解

blob.png

为一个“坑”,每个里面都可以自行去决定里面填充什么内容。最后把所有格里的标题和内容拼接在一起,就形成了最后完整的监测。然而在所有的监测系统中,都有一个问题,在于最终的URL中只能使用英文和数字,而如果想保留监测里保留中文的信息,就需要进行信息的编码与解码。很多人可能认为编码和解码需要用单独的编程软件进行编写。其实,在excel中也有公式能够满足我们的需求。如需进行信息的编码,只需使用“encodeurl”,就可把中文字转化为数字和英文的编码。而解码的公式并不在excel的自带函数中,需要在VB模块中添加对应函数,然后在单元格中输入URLDECODE”,方可使用。

附:URL解码函数(VB)

Function URLDecode(ByVal strIn)

        URLDecode = ""

        Dim sl: sl = 1

        Dim tl: tl = 1

        Dim key: key = "%"

        Dim kl: kl = Len(key)

        sl = InStr(sl, strIn, key, 1)

        Do While sl > 0

            If (tl = 1 And sl <> 1) Or tl < sl Then

                URLDecode = URLDecode & Mid(strIn, tl, sl - tl)

            End If

            Dim hh, hi, hl

            Dim a

            Select Case UCase(Mid(strIn, sl + kl, 1))

                Case "U" 'Unicode URLEncode

                    a = Mid(strIn, sl + kl + 1, 4)

                    URLDecode = URLDecode & ChrW("&H" & a)

                    sl = sl + 6

                Case "E" 'UTF-8 URLEncode

                    hh = Mid(strIn, sl + kl, 2)

                    a = Int("&H" & hh) 'ascii码

                    If Abs(a) < 128 Then

                        sl = sl + 3

                        URLDecode = URLDecode & Chr(a)

                    Else

                        hi = Mid(strIn, sl + 3 + kl, 2)

                        hl = Mid(strIn, sl + 6 + kl, 2)

                        a = ("&H" & hh And &HF) * 2 ^ 12 Or ("&H" & hi And &H3F) * 2 ^ 6 Or ("&H" & hl And &H3F)

                        If a < 0 Then a = a + 65536

                        URLDecode = URLDecode & ChrW(a)

                        sl = sl + 9

                    End If

                Case Else 'Asc URLEncode

                    hh = Mid(strIn, sl + kl, 2) '高位

                    a = Int("&H" & hh) 'ascii码

                    If Abs(a) < 128 Then

                        sl = sl + 3

                    Else

                        hi = Mid(strIn, sl + 3 + kl, 2) '低位

                        a = Int("&H" & hh & hi) '非ascii码

                        sl = sl + 6

                    End If

                    URLDecode = URLDecode & Chr(a)

            End Select

            tl = sl

            sl = InStr(sl, strIn, key, 1)

        Loop

        URLDecode = URLDecode & Mid(strIn, tl)

    End Function